doc: 添加路由缓存说明
This commit is contained in:
@@ -22,18 +22,17 @@ watch(
|
||||
const routeName = newRoute.name as string
|
||||
const shouldCache = newRoute.meta?.cache === true
|
||||
|
||||
console.log('🔄 路由变化:', { routeName, shouldCache, currentCache: cachedViews.value })
|
||||
// console.log('🔄 路由变化:', { routeName, shouldCache, currentCache: cachedViews.value })
|
||||
|
||||
if (shouldCache && routeName && !cachedViews.value.includes(routeName)) {
|
||||
// 添加到缓存列表
|
||||
cachedViews.value.push(routeName)
|
||||
console.log('✅ 添加到缓存:', routeName)
|
||||
// console.log('✅ 添加到缓存:', routeName)
|
||||
} else if (!shouldCache && routeName && cachedViews.value.includes(routeName)) {
|
||||
// 从缓存列表中移除
|
||||
const index = cachedViews.value.indexOf(routeName)
|
||||
if (index > -1) {
|
||||
cachedViews.value.splice(index, 1)
|
||||
console.log('❌ 从缓存移除:', routeName)
|
||||
// console.log('❌ 从缓存移除:', routeName)
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user