当前位置:网站首页>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 .
边栏推荐
- JS array
- PHP reverses scenarios based on code and skillfully uses debug_ backtrace()
- Service online governance
- KnightCTF WEB
- 【Kubernetes系列】K8s设置MySQL8大小写不敏感
- Comprehensively analyze the basic features and summary of free and paid SSH tools
- PHP conditional operator
- Initial attack and defense world Misc
- PHP multidimensional array sorting
- Geoffreyhinton: my 50 years of in-depth study and Research on mental skills
猜你喜欢

QQ 居然被盗了?原因在这......

Google Earth engine (GEE) - ghsl: global human settlements layer, built grid 1975-1990-2000-2015 (p2016) data set

QQ was stolen? The reason is

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?)

Thinkphp5 log file contains trick

What network security problems are exposed when a large-scale QQ number theft event occurs?

Google Earth engine (GEE) -- converts string to number and applies it to time search (ee.date.fromymd)

The first three passes of sqli Labs
![[scientific research data processing] [basic] category variable frequency analysis chart, numerical variable distribution chart and normality test (including lognormal)](/img/70/8bf226964118efb324ca4d339df654.png)
[scientific research data processing] [basic] category variable frequency analysis chart, numerical variable distribution chart and normality test (including lognormal)

The first dark spring cup dnuictf
随机推荐
数据恢复软件EasyRecovery15下载
MFQE 2.0: A New Approach for Multi-FrameQuality Enhancement on Compressed Video
@Component use cases
【Kubernetes系列】K8s设置MySQL8大小写不敏感
V3_ Chrome extended Chinese translation document V3 directory
Go language func function
[buuctf] [geek challenge 2019] secret file
Go common lock mutex and rwmutex
PHP reverses scenarios based on code and skillfully uses debug_ backtrace()
Wuenda 2022 machine learning special course evaluation is coming!
深入理解.Net中的线程同步之构造模式(二)内核模式4.内核模式构造物的总结
How to execute a query SQL
Fastcgi CGI shallow understanding
Cost forecast of PMP (BAC, EAC, etc)
PHP recursive multi-level classification, infinite classification
Meaning of while (~scanf ("%d%d", & A, & B))
ot initialized – call ‘refresh’ before invoking lifecycle methods via the context: Root WebApplicati
Tencent two sides: @bean and @component are used on the same class. What happens?
想请教一下,我在佛山,到哪里开户比较好?手机开户是安全么?
go time. after