Open ytxbnahn opened 7 years ago
使用vue-router做路由时,跳转页面后返回,原页面刷新。
使用keep-alive 组件会被缓存。
const router = new VueRouter({ routes: [{ path: '/', component: Index, meta: { keepAlive: true }] }) `
const router = new VueRouter({
routes: [{
path: '/',
component: Index,
meta: {
keepAlive: true
}]
})
created: function () { console.log(1) }, mounted: function () { console.log(2) }, activated: function () { console.log(3) }, deactivated: function () { console.log(4) } ` 页面第一次进入,钩子的触发顺序created-> mounted-> activated,退出时触发deactivated。当再次进入(前进或者后退)时,只触发activated。
vuex我觉得解决这个问题好一些
问题
使用vue-router做路由时,跳转页面后返回,原页面刷新。
解决
使用keep-alive 组件会被缓存。
方法
const router = new VueRouter({
routes: [{
path: '/',
component: Index,
meta: {
keepAlive: true
}]
})
`思考
vuex我觉得解决这个问题好一些