profile
viewpoint

Ask questions关于keep-alive缓存页面问题请教

Version

2.6.9

Reproduction link

https://jsfiddle.net/chrisvfritz/50wL7mdz/

Steps to reproduce

单页面应用缓存

What is expected?

页面已缓存且缓存清除

What is actually happening?

页面已缓存且缓存清除,但页面组件未删除

<!-- generated by vue-issues. DO NOT REMOVE --> 不知道上面是干嘛的,忽略不计

看了相关页面缓存的解决方案,建议用keep-alive的include或exclude属性实现。我也用exclude实现了单页面应用。所有的页面默认缓存,点击左侧菜单栏,会在头部加载一个tab,点击tab从缓存读取页面,点击左侧菜单因该菜单对应页面已存在用exclude加入该页面,页面刷新,然后调用nextTick清空exclude。但是这样强制刷新有一个问题,用vue调试工具发现点击左侧菜单强制刷新之前缓存的组件并没有删除,会在页面继续追加一个,我不停的点击左侧菜单刷新页面缓存组件就会不停的追加下去,这是为啥,怎么解决呢?还望指点一下

擷取

vuejs/vue

Answer questions posva

Hi, thanks for your interest but Github issues are for bug reports and feature requests only. You can ask questions on the forum, the Discord server or StackOverflow.

useful!

Related questions

force re-computation of a computed property hot 2
Error thrown when using transition-group with conditionally rendered children hot 2
[Vue warn]: Error in nextTick: "RangeError: Maximum call stack size exceeded" while navigating to another route hot 1
Can not clear slot content with vue@2.5.3 hot 1
TypeError: Cannot read property 'toLowerCase' of undefined at emptyNodeAt hot 1
VNode.componentInstance is undefined when rendered by a functional component hot 1
Korean input trigger keydown event twice hot 1
Proposal: Template inheritance using the slots mechanism hot 1
Memory leak when using "transition" and "keep-alive" hot 1
Error in v-on handler: "RangeError: Maximum call stack size exceeded" hot 1
如何通过v-bind:style动态生成背景图? hot 1
如何通过v-bind:style动态生成背景图? hot 1
Different functional componens has the same key hot 1
IE11, console print: [Vue warn]: Error in nextTick: "Error: Invalid argument." But work well with chrome hot 1
v-bind:style 'background-image' error: url is not a function hot 1
Github User Rank List