As long as my project has the keep-alive tag, no matter what you write in exclude, it will cache all pages.
<keep-alive exclude="xxx,yyy">
<router-view></router-view>
</keep-alive>
Need a solution?
ringa_lee2017-05-19 10:37:48
I also found this problem, the include is the same, it doesn’t work! Please why
为情所困2017-05-19 10:37:48
Currently it seems that you cannot use include and exclude directly when using vue-router
I can only write like this
<keep-alive>
<router-view v-if="$route.meta.keepAlive"></router-view>
</keep-alive>
<router-view v-if="!$route.meta.keepAlive"></router-view>
Refer to issue#811 of vue-router
过去多啦不再A梦2017-05-19 10:37:48
exclude is no problem at all,
a few points to note,
vue-router version must be 2.1+
For components with exclude set, if the component with the same name is switched, it will still be cached. This is because the components are reused
Set a name to the component
exclude sets the name of the corresponding component
https://jsfiddle.net/lincenyi...
Open the above example,
Click /params/foo
and the content will change from 1234 at the beginning to 2345 after 1 second/params/foo
内容会由一开始的1234, 1秒后变成2345
再点击/optional-group/foo/bar
最后再点击/params/foo
Click again /optional-group/foo/bar
/params/foo
, and the result will be 1234, which changes to 2345 after 1 second, indicating that the component has not been cached
exclude="foo2"
Delete
in the code
Repeat the above 3 steps again,