当前位置:网站首页>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>
边栏推荐
- Select sort and bubble sort
- 漫画:程序员不是修电脑的!
- CODING DevSecOps 助力金融企业跑出数字加速度
- GPS原始坐标转百度地图坐标(纯C代码)
- Type declaration of all DOM elements in TS
- 机器学习笔记 - 灰狼优化
- How to paste the contents copied by the computer into mobaxterm? How to copy and paste
- Common redis data types and application scenarios
- What are the domestic formal futures company platforms in 2022? How about founder metaphase? Is it safe and reliable?
- Shanghai under layoffs
猜你喜欢
随机推荐
I spring web upload
Bugku cyberpunk
Photoshop插件-动作相关概念-非加载执行动作文件中动作-PS插件开发
The difference between abstract classes and interfaces in PHP (PHP interview theory question)
sql server char nchar varchar和nvarchar的区别
Huawei Hubble incarnation hard technology IPO harvester
想问下大家伙,有无是从腾讯云MYSQL同步到其他地方的呀?腾讯云MySQL存到COS上的binlog
Handwriting promise and async await
Surpass palm! Peking University Master proposed diverse to comprehensively refresh the NLP reasoning ranking
Ctfshow web entry information collection
ICML 2022 | explore the best architecture and training method of language model
Ctfshow web entry command execution
P1451 calculate the number of cells / 1329: [example 8.2] cells
复现Thinkphp 2.x 任意代码执行漏洞
做研究无人咨询、与学生不交心,UNC助理教授两年教职挣扎史
Bugku alert
DVWA range clearance tutorial
Interpretation of Apache linkage parameters in computing middleware
CPU design practice - Chapter 4 practice task 3 use pre delivery technology to solve conflicts caused by related issues
Number protection AXB function! (essence)



![1330: [example 8.3] minimum steps](/img/69/9cb13ac4f47979b498fa2254894ed1.gif)




