当前位置:网站首页>keep-alive
keep-alive
2022-07-05 15:21:00 【Shepherd Wolf】

app.vue:
Need one : When all pages jump to the home page , Cache all home pages ( Do not reload )
router/index.js:

Demand two :list When you jump to the home page , Reload the homepage ;about When you jump to the home page , Home page does not reload
【 Implementation steps 】:
1. The route of the home page : Get rid of the dead meta.keepAlive;
2. Inside other page components : In the navigation guard when the page leaves , Dynamically add the target page keepAlive Value
router/index.js:
list.vue:
about.vue:
Now? , So let's verify that ( page mounted Hook printing 111), Change the input box of the home page to :zhang.
Click to list page , Then return to the home page , I found that the input box changed back :zhangsan, And mounted Printed 111 Print again , explain : Page reload , Not cached 
Then click about page , Then return to the home page , Find that the input box changes to :zhang, And mounted Not executed again , explain : Page not reloaded , Cached 
app.vue:
<template>
<div id="app">
<div id="nav">
<router-link to="/">Home</router-link> |
<router-link to="/list">List</router-link> |
<router-link to="/about">About</router-link>
</div>
<keep-alive>
<router-view v-if="$route.meta.keepAlive"></router-view>
</keep-alive>
<router-view v-if="!$route.meta.keepAlive"></router-view>
</div>
</template>
<style>
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
}
#nav {
padding: 30px;
}
#nav a {
font-weight: bold;
color: #2c3e50;
}
#nav a.router-link-exact-active {
color: #42b983;
}
</style>
边栏推荐
- Huiyuan, 30, is going to have a new owner
- R 熵权法计算权重及综合得分
- Calculate weight and comprehensive score by R entropy weight method
- Detailed explanation of usememo, memo, useref and other relevant hooks
- Ecotone technology has passed ISO27001 and iso21434 safety management system certification
- Machine learning notes - gray wolf optimization
- Jmeter性能测试:ServerAgent资源监控
- Easyocr character recognition
- 漫画:优秀的程序员具备哪些属性?
- Reconnaissance des caractères easycr
猜你喜欢

729. My schedule I: "simulation" & "line segment tree (dynamic open point) &" block + bit operation (bucket Division) "

Stop B makes short videos, learns Tiktok to die, learns YouTube to live?

Common MySQL interview questions

做研究无人咨询、与学生不交心,UNC助理教授两年教职挣扎史

qt creater断点调试程序详解

Ionic Cordova project modification plug-in

你童年的快乐,都是被它承包了

B站做短视频,学抖音死,学YouTube生?

Ecotone technology has passed ISO27001 and iso21434 safety management system certification

No one consults when doing research and does not communicate with students. UNC assistant professor has a two-year history of teaching struggle
随机推荐
Bugku's eyes are not real
Can I pass the PMP Exam in 20 days?
MySQL----函数
Fr exercise topic - simple question
如何将 DevSecOps 引入企业?
How can the boss choose programmers to help me with development?
Leetcode: Shortest Word Distance II
Ionic Cordova project modification plug-in
Visual task scheduling & drag and drop | scalph data integration based on Apache seatunnel
Talk about your understanding of microservices (PHP interview theory question)
Reconnaissance des caractères easycr
Ecotone technology has passed ISO27001 and iso21434 safety management system certification
JS bright blind your eyes date selector
CPU design related notes
maxcompute有没有能查询 表当前存储容量的大小(kb) 的sql?
DVWA range clearance tutorial
I collect multiple Oracle tables at the same time. After collecting for a while, I will report that Oracle's OGA memory is exceeded. Have you encountered it?
Handwriting promise and async await
First PR notes
Redis distributed lock principle and its implementation with PHP (2)