当前位置:网站首页>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>
边栏推荐
- Stop B makes short videos, learns Tiktok to die, learns YouTube to live?
- Detailed explanation of usememo, memo, useref and other relevant hooks
- Surpass palm! Peking University Master proposed diverse to comprehensively refresh the NLP reasoning ranking
- I spring and autumn blasting-2
- No one consults when doing research and does not communicate with students. UNC assistant professor has a two-year history of teaching struggle
- Redis distributed lock principle and its implementation with PHP (2)
- 可视化任务编排&拖拉拽 | Scaleph 基于 Apache SeaTunnel的数据集成
- P1451 calculate the number of cells / 1329: [example 8.2] cells
- DVWA range clearance tutorial
- 如何将 DevSecOps 引入企业?
猜你喜欢
华为哈勃化身硬科技IPO收割机
NBA赛事直播超清画质背后:阿里云视频云「窄带高清2.0」技术深度解读
How can I quickly check whether there is an error after FreeSurfer runs Recon all—— Core command tail redirection
Bugku's steganography
Stop B makes short videos, learns Tiktok to die, learns YouTube to live?
Photoshop plug-in action related concepts actionlist actiondescriptor actionlist action execution load call delete PS plug-in development
Au - delà du PARM! La maîtrise de l'Université de Pékin propose diverse pour actualiser complètement le classement du raisonnement du NLP
Surpass palm! Peking University Master proposed diverse to comprehensively refresh the NLP reasoning ranking
Bugku cyberpunk
Bugku's Ah Da
随机推荐
计算中间件 Apache Linkis参数解读
episodic和batch的定义
What are CSRF, XSS, SQL injection, DDoS attack and timing attack respectively and how to prevent them (PHP interview theory question)
Huawei Hubble incarnation hard technology IPO harvester
亿咖通科技通过ISO27001与ISO21434安全管理体系认证
Usage and usage instructions of JDBC connection pool
P1451 calculate the number of cells / 1329: [example 8.2] cells
超越PaLM!北大碩士提出DiVeRSe,全面刷新NLP推理排行榜
GPS原始坐标转百度地图坐标(纯C代码)
I spring web upload
The difference between abstract classes and interfaces in PHP (PHP interview theory question)
Aike AI frontier promotion (7.5)
爱可可AI前沿推介(7.5)
Coding devsecops helps financial enterprises run out of digital acceleration
STM32+BH1750光敏传感器获取光照强度
MySQL之CRUD
Common MySQL interview questions
R 熵权法计算权重及综合得分
Stop B makes short videos, learns Tiktok to die, learns YouTube to live?
Change multiple file names with one click