Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[vue] 怎么缓存当前打开的路由组件,缓存后想更新当前组件怎么办呢? #427

Open
haizhilin2013 opened this issue Jun 22, 2019 · 5 comments
Labels
vue vue

Comments

@haizhilin2013
Copy link
Collaborator

[vue] 怎么缓存当前打开的路由组件,缓存后想更新当前组件怎么办呢?

@haizhilin2013 haizhilin2013 added the vue vue label Jun 22, 2019
@wenyejie
Copy link

可以在路由meta中加入参数, 对打开的路由进行keep-alive的判断, 通过钩子active等

@Brayshen
Copy link

Brayshen commented Nov 8, 2019

优秀~

@SecondLiang
Copy link

@Drikold
Copy link

Drikold commented Jul 26, 2021

设置缓存:

<keep-alive>
      <router-view v-if="$route.meta.keepAlive" />
</keep-alive>
<router-view v-if="!$route.meta.keepAlive" />

更新当前组件,设置不同:key键;activated中更新数据;

@zhuyu1220
Copy link

1.通过keep-alive组件可以缓存 组件,通过路由配置中的meta选项中的自定义属性trueorfalse决定缓存,或者使用include属性来添加缓存的组件
2.key值的改变组件会进行重建,因此可以再actived中改变key值

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
vue vue
Projects
None yet
Development

No branches or pull requests

6 participants