问题:
标题栏的tabs的右键:刷新时,没有保存上一个页面传递过来的参数
分析:
TagView.vue刷新事件
function refreshSelectedTag(view: TagView) { console.log('|--执行刷新', view) tagsViewStore.delCachedView(view); const {fullPath} = view; nextTick(() => { router.replace({path: "/redirect" + fullPath}); }); }刷新获取到当前路由,没有把route里的路由参数对象拿出来,query
解决:
首先添加tag时,把query也添加到tag view里
//src\layout\components\TagsView.vue
function addTags() {
if (route.meta.title) {
tagsViewStore.addView({
name: route.name as string,
title: route.meta.title,
path: route.path,
fullPath: route.fullPath,
affix: route.meta?.affix,
keepAlive: route.meta?.keepAlive,
query: route.query,
});
}
}
执行右键: 【刷新】事件把query拿回来
function refreshSelectedTag(view: TagView) {
console.log('|--执行刷新', view)
tagsViewStore.delCachedView(view);
const {fullPath, query} = view;
nextTick(() => {
router.replace({path: "/redirect" + fullPath, query});
});
}
在需要刷新:xx.vue页面
在onActivate地方重置获取一下,再执行刷新事件并请求最新的数据
onActivated(() => { //刷新时候保存query planInfor.value.id = route.query.id getDetailRequest() })