In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces how to use keep-alive in vue2.0. It is very detailed and has a certain reference value. Friends who are interested must finish it!
1. Basic usage
Vue2.0 provides a keep-alive component for caching components to avoid loading the corresponding components multiple times and reduce performance consumption
Sometimes you may need to cache all the pages of the entire site, and the request is usually triggered as soon as the page is entered.
In the case of keep-alive
Caching can be implemented by writing the first trigger request in the created hook function
For example, the list page, if you go to the details page, it is still on the original page.
two。 Cache part of the page or component
(1) using router. Meta attribute
/ / this is the most commonly used method at present.
Router Settin
... Routes: [{path:'/', redirect:'/ index', component: Index, meta: {keepAlive: true}}, {path:'/ common', component: TestParent, children: [{path:'/ test2', component: Test2, meta: {keepAlive: true}}]}. / / indicates that both index and test2 use keep-alive
(2)。 Use the new property inlcude/exclude
After 2.1.0, two attributes of include/exclude are provided to cache the corresponding components.
/ / where aformab is the name of the component
Note: this method knows the name of the component in advance.
(3) dynamic judgment
IncludedComponents can be set dynamically.
The above is all the contents of the article "how to use keep-alive in vue2.0". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.