20251205优化数据请求逻辑
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
text-color="#2E7D32"
|
||||
active-text-color="#1B5E20"
|
||||
:default-active="this.$route.path"
|
||||
router
|
||||
@select="handleMenuSelect"
|
||||
>
|
||||
<el-submenu index="1">
|
||||
<template slot="title">
|
||||
@@ -44,7 +44,22 @@ export default {
|
||||
data() {
|
||||
return {};
|
||||
},
|
||||
method: {},
|
||||
methods: {
|
||||
// 处理菜单选择,避免重复导航
|
||||
handleMenuSelect(index) {
|
||||
// 如果点击的是当前路径,阻止导航
|
||||
if (this.$route.path === index) {
|
||||
return false;
|
||||
}
|
||||
// 否则正常导航
|
||||
this.$router.push({ path: index }).catch(err => {
|
||||
// 忽略 NavigationDuplicated 错误
|
||||
if (err.name !== 'NavigationDuplicated') {
|
||||
console.error('路由导航错误:', err);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
</script>
|
||||
<style scoped>
|
||||
|
||||
Reference in New Issue
Block a user