Leanote's Blog
I love Leanote!
Toggle navigation
Leanote's Blog
Home
Chrome
Git
Linux
Windows
Others
工具大全
VsCode
Expo
Html
JavaScript
Npm
Node
Mock
React-Native
React
TypeScript
小程序
插件
正则
Dva
Ant-Design-React
Umi
Vue
Vux
Ant-Design-Vue
Http
Java
flutter
开发小工具
About Me
Archives
Tags
vue keep-alive使用问题
2021-04-01 07:49:01
35
0
0
admin
### 动态缓存组件 - 使用`keep-alive`的`include`, 动态控制状态 ### 不能缓存多层级路由 - 解决: 干掉中间空白路由, 只支持3层路由 1. 使用`include`或者`exclude` 2. 二级`router-view`设置组件`name`属性 3. 在`router.beforeEach`中加入如下代码 ``` if (to.matched && to.matched.length > 2) { for (let i = 0; i < to.matched.length; i++) { const element = to.matched[i] if (element.components.default.name === 'Blank') { to.matched.splice(i, 1) } } } ```
Pre:
vue函数式组件
Next:
TortoiseGit使用笔记
0
likes
35
Weibo
Wechat
Tencent Weibo
QQ Zone
RenRen
Submit
Sign in
to leave a comment.
No Leanote account?
Sign up now.
0
comments
More...
Table of content
No Leanote account? Sign up now.