feat(sidenav): add default expanded (#200)

This commit is contained in:
Wei Sheng 2022-06-30 10:55:16 +08:00 committed by GitHub
parent af235ed036
commit 1fa7740e92
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -15,6 +15,12 @@ const useComputed = (props) => {
const active = computed(() => getActive()); const active = computed(() => getActive());
const defaultExpanded = computed(() => {
const path = getActive();
const parentPath = path.substring(0, path.lastIndexOf('/'));
return parentPath === '' ? [] : [parentPath];
});
const sideNavCls = computed(() => { const sideNavCls = computed(() => {
const { isCompact } = props; const { isCompact } = props;
return [ return [
@ -44,6 +50,7 @@ const useComputed = (props) => {
return { return {
active, active,
defaultExpanded,
collapsed, collapsed,
sideNavCls, sideNavCls,
menuCls, menuCls,
@ -130,6 +137,7 @@ export default defineComponent({
class={this.menuCls} class={this.menuCls}
theme={this.theme} theme={this.theme}
value={this.active} value={this.active}
default-expanded={this.defaultExpanded}
collapsed={this.collapsed} collapsed={this.collapsed}
v-slots={{ v-slots={{
logo: () => logo: () =>