We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
vue2+版本keep-alive如果使用自定义key来缓存视图,关闭视图后缓存是无法被删除干净的 参考资料 可以维护一个keepExclude 数组来处理,大概是这样
vue2+
keep-alive
watch: { // 需实时移除缓存fullPath集合 keepExclude(v) { const me = this; // 判断是否空数组,避免死循环 if (!isEmpty(v)) { // 遍历清除缓存 v.forEach((name) => { // 在前视图的子视图中查找是否存在动态清除缓存的页面 const view = find(me.$children, (item) => { return item.$vnode && item.$vnode.key == name; }); if (view) { // 如果存在则销毁视图来清除缓存 // 需要先从keep-alive缓存中清除数据,避免下次使用时无法缓存 const { parent } = view.$vnode, // 缓存组件列表 cache = parent.componentInstance.cache, // 缓存组件key列表 keys = parent.componentInstance.keys; remove(keys, (data) => { return data == name; }); // 销毁缓存 delete cache[name]; // 销毁组件 view.$destroy(); // console.log(keys); } }); // 清空需要动态清除缓存的页面集合 me.keepExcludeClean(); } } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
vue2+
版本keep-alive
如果使用自定义key来缓存视图,关闭视图后缓存是无法被删除干净的参考资料
可以维护一个keepExclude 数组来处理,大概是这样
The text was updated successfully, but these errors were encountered: