Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5034b0f

Browse files
include/exclude for keep-alive
1 parent 90788bf commit 5034b0f

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

‎src/v2/api/index.md‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1779,6 +1779,10 @@ All lifecycle hooks automatically have their `this` context bound to the instanc
17791779

17801780
### keep-alive
17811781

1782+
- **Props:**
1783+
- `include` - string or RegExp. Only components matched by this will be cached.
1784+
- `exclude` - string or RegExp. Any component matched by this will not be cached.
1785+
17821786
- **Usage:**
17831787

17841788
When wrapped around a dynamic component, `<keep-alive>` caches the inactive component instances without destroying them. Similar to `<transition>`, `<keep-alive>` is an abstract component: it doesn't render a DOM element itself, and doesn't show up in the component parent chain.
@@ -1807,6 +1811,26 @@ All lifecycle hooks automatically have their `this` context bound to the instanc
18071811
</transition>
18081812
```
18091813

1814+
- **`include` and `exclude`**
1815+
1816+
> New in 2.1.0
1817+
1818+
The `include` and `exclude` props allow components to be conditionally cached. Both props can either be a comma-delimited string or a RegExp:
1819+
1820+
``` html
1821+
<!-- comma-delimited string -->
1822+
<keep-alive include="a,b">
1823+
<component :is="view"></component>
1824+
</keep-alive>
1825+
1826+
<!-- regex (use v-bind) -->
1827+
<keep-alive :include="/a|b/">
1828+
<component :is="view"></component>
1829+
</keep-alive>
1830+
```
1831+
1832+
The match is first checked on the component's own `name` option, then its local registration name (the key in the parent's `components` option) if the `name` option is not available. Anonymous components cannot be matched against.
1833+
18101834
<p class="tip">`<keep-alive>` does not work with functional components because they do not have instances to be cached.</p>
18111835

18121836
- **See also:** [Dynamic Components - keep-alive](../guide/components.html#keep-alive)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /