修复页面布局导致的首页有时无法路由的bug
This commit is contained in:
@@ -48,9 +48,15 @@ const toggleSidebar = () => {
|
||||
}
|
||||
|
||||
// 监听路由变化,在移动端自动关闭侧边栏
|
||||
watch(() => useRoute().path, () => {
|
||||
const route = useRoute()
|
||||
const stopWatch = watch(() => route.path, () => {
|
||||
if (isSidebarOpen.value) {
|
||||
isSidebarOpen.value = false
|
||||
}
|
||||
})
|
||||
|
||||
// 组件卸载时清理监听器
|
||||
onUnmounted(() => {
|
||||
stopWatch()
|
||||
})
|
||||
</script>
|
Reference in New Issue
Block a user