问题描述
触发route是添加页面缓存,删除对应的tab时删除该页面的缓存
问题出现的环境背景及自己尝试过哪些方法
现在用的是keep-alive里的:include=”cached”
但是要在很多页面加name
代码:
“
触发route添加tab
setTab (title, path, query, pathName) {
if (this.tabData.find(i => i.title === title)) return
let name = ++this.currentname + ''
if (pathName) {
this.setCached(pathName) // 缓存到vuex
}
this.tabData.push({title, path, name, query})
this.tabIndex = name
},
点击删除tab时
if (this.tabData.length > 0) {
let item = this.tabData.find(i => i.name === activeName)
let index = this.tabData.findIndex(i => i.name === activeName)
this.removCached(index) // 删除对应vuex 清除缓存
this.$router.push({path: item.path, query: item.query})
}
“