1. FunctionMainly used to preserve component state or avoid re-rendering. 2. Usage<keep-alive> When wrapping a dynamic component, inactive component instances are cached instead of being destroyed. <keep-alive> is an abstract component: it does not render a DOM element itself, nor does it appear in the component's parent chain. When a component is switched within <keep-alive>, its activated and deactivated lifecycle hook functions will be executed accordingly. 3. Props includeinclude - a string or a regular expression. Only components with matching names will be cached. excludeexclude - a string or regular expression. Any components with matching names will not be cached. The include and exclude props allow components to be conditionally cached. Both can be expressed as a comma-delimited string, a regular expression, or an array: <!-- Comma separated string --> <keep-alive include="a,b"> <component :is="view"></component> </keep-alive> <!-- Regular expression (using `v-bind`) --> <keep-alive :include="/a|b/"> <component :is="view"></component> </keep-alive> <!-- Array (using `v-bind`) --> <keep-alive :include="['a', 'b']"> <component :is="view"></component> </keep-alive> Matching is first checked against the component's own name option, or if that is not available, against its locally registered name (the value of the parent component's components option key). Anonymous components cannot be matched. maxmax : a number. The maximum number of component instances that can be cached. Once this number is reached, the cached component instance that has not been accessed in the longest time will be destroyed before a new instance is created. <keep-alive :max="10"> <component :is="view"></component> </keep-alive> The above is a brief analysis of the details of keep-alive in vue. For more information about keep-alive in vue, please pay attention to other related articles on 123WORDPRESS.COM! You may also be interested in:
|
>>: CentOS 7 configuration Tomcat9+MySQL solution
1. Autoflow attribute, if the length and width of...
This article shares the specific code of JavaScri...
Recently, the company has begun to evaluate all s...
Table of contents Workaround Why can't I moni...
Table of contents 1. What is Dockerfile? 2. Analy...
The <canvas> element is designed for client...
Table of contents - Preface - - JVM Class Loader ...
This article shares the specific code of Vue usin...
I learned a new trick today. I didn’t know it befo...
In the previous article, we introduced the MySQL ...
rep / egrep Syntax: grep [-cinvABC] 'word'...
Install CentOS 7 after installing VirtualBox. I w...
Zabbix 2019/10/12 Chenxin refer to https://www.za...
The first step is to create a mysql container doc...
This article shares the specific code of jQuery t...