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