Skip to content

针对同一个path 不同的参数 tagsView的store里的页签数据 只保留了第一次进去的参数 不会更新 页面缓存 #632

@15515222108

Description

@15515222108

1、ABC三个页面 C是缓存页面
2、A先进入C 携带的参数是 query:{id: 1} 这个时候页签store里存的c的path对应的数据包括参数是query:{id: 1}
3、B然后进入C 携带的参数是 query:{id: 2} 这个时候页签store里存的c的path对应的数据包括参数仍然是query:{id: 1}
4、所以就会导致 我去了其他页面 再点击页签回到C的时候 参数就会一直是第一次存进去的数据 永远不会是最新的
5、主要是这行代码 如果c存在了 就直接return出来了

Image

6、解决方案:
每次进入C页面的时候 判断一下store里有没有这个c的数据 如果有就替换 没有才push进去

// 新增tag
addVisitedView(view: RouteLocationNormalizedLoaded) {
if (view.meta?.noTagsView) return
const findIndex = this.visitedViews.findIndex((v) => v.path === view.path)
if (findIndex !== -1) {
this.visitedViews[findIndex] = Object.assign({}, view, {
title: view.meta?.title || 'no-name'
})
} else {
this.visitedViews.push(
Object.assign({}, view, {
title: view.meta?.title || 'no-name'
})
)
}
}

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions