当前位置:网站首页>Clear the route cache in Vue
Clear the route cache in Vue
2022-06-30 14:31:00 【Bamboo shrimp】
scene :
A Jump B,B Jump C.B stay A The first jump B When , Made a cache ,A Jumping around B When , You won't go through the life cycle again .
But the real scene is ,A In every time Jump B When , Want to refresh , and C Back in B When ,B Need to keep the scene , That is to say, using cache to render .
Here's the picture :
Now comes the question , How to solve the problem in the purple circle , eliminate pageB Page cache .
Solutions :
Each time the pageB return pageA When , eliminate pageB Cache data .
So next time pageA Jump pageB When , The first cached data will not be read because there is cached data , And in the pageC return pageB When , Also read the first cache pageB The data of the , because , Every time pageB Cache data , Back in pageA It will be empty when .
The specific needs are pageB Add the following code to :
Be careful beforeRouteLeave Is and methods Of the same rank
beforeRouteLeave (to, from, next) {
if (to.name === 'pageA') {
// console.log(' Go back to the administration page ')
if (this.$vnode && this.$vnode.data.keepAlive) {
if (this.$vnode.parent && this.$vnode.parent.componentInstance && this.$vnode.parent.componentInstance.cache) {
if (this.$vnode.componentOptions) {
var key = this.$vnode.key == null
? this.$vnode.componentOptions.Ctor.cid + (this.$vnode.componentOptions.tag ? `::${
this.$vnode.componentOptions.tag}` : '')
: this.$vnode.key
var cache = this.$vnode.parent.componentInstance.cache
var keys = this.$vnode.parent.componentInstance.keys
if (cache[key]) {
if (keys.length) {
var index = keys.indexOf(key)
if (index > -1) {
keys.splice(index, 1)
}
}
delete cache[key]
}
}
}
}
this.$destroy()
}
next()
},
Has the problem been solved ? If you have any questions, welcome to discuss .
边栏推荐
- Att & CK red team evaluation field (I)
- Notepad regular delete the line of the keyword
- ThinkPHP v3.2 comment annotation injection write shell
- 用Unity实现Flat Shading
- notepad正则删除关键词所在行
- NoViableAltException([email protected][])
- XSS challenge (6-10) more detailed answers
- "Persistent diseases" that cannot be solved in IM application development
- Laravel RBAC laravel permission use
- XSS challenge (1-5) more detailed answers
猜你喜欢

Pytoch viewing model parameter quantity and calculation quantity

用Unity实现Flat Shading

Tencent two sides: @bean and @component are used on the same class. What happens?

Getting started with shell Basics

Deep understanding Net (2) kernel mode 2 Kernel mode construct semaphone

About the problems encountered when using the timer class to stop with a button (why does the QPushButton (for the first time) need to be clicked twice to respond?)

Detailed explanation of the first three passes of upload Labs
![[buuctf] [actf2020 freshman competition]exec1](/img/af/22051a5feb3c1f6d7201a483bde127.jpg)
[buuctf] [actf2020 freshman competition]exec1

Zend studio how to import an existing project

XSS challenge (1-5) more detailed answers
随机推荐
remote: Support for password authentication was removed on August 13, 2021. Please use a personal ac
V3 01_ Welcome
Ctfshow getting started with the web (ThinkPHP topic)
Comprehensively analyze the basic features and summary of free and paid SSH tools
XSS challenge (1-5) more detailed answers
ot initialized – call ‘refresh’ before invoking lifecycle methods via the context: Root WebApplicati
Three uses of golang underscores
I'd like to ask you, where can I open an account in Foshan? Is it safe to open a mobile account?
Configuration of headquarters dual computer hot standby and branch infrastructure for firewall Foundation
Complete TCP forwarding server (kernel linked list + mutex)
PHP generate images into Base64
Use PHP to delete the specified text content in the file
V3 03_ Getting started
【BUUCTF】 Have Fun
Step by step | help you easily submit Google play data security form
Thinkphp5 log file contains trick
What network security problems are exposed when a large-scale QQ number theft event occurs?
Detailed explanation of the first three passes of upload Labs
Advanced usage of go language for loop break and continue
编程实战赛来啦!B站周边、高级会员等好礼送你啦!