<template>
<keep-alive include="a, b, c">
<router-view />
</keep-alive>
</template>
上面这样使用只有第一个组件a能缓存,b和c都不能缓存。
切记:使用逗号分隔字符串这种形式,不能有空格
<template>
<keep-alive include="a,b,c">
<router-view />
</keep-alive>
</template>
或者使用数组形式(数组 使用 `v-bind`)
<template>
<keep-alive :include="['a', 'b']">
<router-view />
</keep-alive>
</template>