当前位置:网站首页>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>
边栏推荐
- The difference between abstract classes and interfaces in PHP (PHP interview theory question)
- Bugku telnet
- Number protection AXB function! (essence)
- easyOCR 字符識別
- Huiyuan, 30, is going to have a new owner
- [recruitment position] infrastructure software developer
- How can the boss choose programmers to help me with development?
- Bugku's Ah Da
- How to paste the contents copied by the computer into mobaxterm? How to copy and paste
- lv_font_conv离线转换
猜你喜欢
Database learning - Database Security
[JVM] operation instruction
1330:【例8.3】最少步数
How to paste the contents copied by the computer into mobaxterm? How to copy and paste
Super wow fast row, you are worth learning!
Photoshop插件-动作相关概念-ActionList-ActionDescriptor-ActionList-动作执行加载调用删除-PS插件开发
SQL Server learning notes
P6183 [USACO10MAR] The Rock Game S
Machine learning notes - gray wolf optimization
P1451 calculate the number of cells / 1329: [example 8.2] cells
随机推荐
Surpass palm! Peking University Master proposed diverse to comprehensively refresh the NLP reasoning ranking
复现Thinkphp 2.x 任意代码执行漏洞
CPU design practice - Chapter 4 practical task 2 using blocking technology to solve conflicts caused by related problems
Usage and usage instructions of JDBC connection pool
NBA赛事直播超清画质背后:阿里云视频云「窄带高清2.0」技术深度解读
Magic methods and usage in PHP (PHP interview theory questions)
lvgl 显示图片示例
Select sort and bubble sort
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?
Run faster with go: use golang to serve machine learning
Severlet learning foundation
OSI 七层模型
我这边同时采集多个oracle表,采集一会以后,会报oracle的oga内存超出,大家有没有遇到的?
百亿按摩仪蓝海,难出巨头
Super wow fast row, you are worth learning!
[recruitment position] Software Engineer (full stack) - public safety direction
Bugku telnet
MySQL----函数
Mongdb learning notes
I include of spring and Autumn