improve menuitem route by vue3.4'defineModel

This commit is contained in:
w 2024-03-31 00:09:49 +08:00
parent 13505fdedc
commit 440dbf8aac
2 changed files with 9 additions and 3 deletions

View File

@ -8,7 +8,7 @@
</template>
{{ renderMenuTitle(item.title) }}
</t-menu-item>
<t-menu-item v-else :name="item.path" :value="getPath(item)" :to="item.path">
<t-menu-item v-else :name="item.path" :value="getPath(item)" :to="item.path" @click="doMenuItemClick(item)">
<template #icon>
<component :is="menuIcon(item)" class="t-icon"></component>
</template>
@ -41,7 +41,8 @@ const props = defineProps({
},
});
const active = computed(() => getActive());
const active = defineModel<string>({ default: '' });
//const active = computed(() => getActive());
const { locale } = useLocale();
const list = computed(() => {
@ -106,6 +107,11 @@ const getPath = (item: ListItemType) => {
return item.meta?.single ? item.redirect : item.path;
};
const doMenuItemClick = (item: ListItemType) => {
//window.open(url);
active.value= item.path;
};
const openHref = (url: string) => {
window.open(url);
};

View File

@ -6,7 +6,7 @@
<component :is="getLogo()" :class="logoCls" />
</span>
</template>
<menu-content :nav-data="menu" />
<menu-content :nav-data="menu" v-model:active="active"/>
<template #operations>
<span :class="versionCls"> {{ !collapsed ? 'TDesign Starter' : '' }} {{ pgk.version }} </span>
</template>