vue3+vite模版框架 tabs右键刷新时丢失路由参数

问题:

标题栏的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()
})
相关推荐
cch89184 分钟前
React Hooks的支持
前端·javascript·react.js
鹏程十八少24 分钟前
9. Android Shadow插件化如何解决资源冲突问题和实现tinker热修复资源(源码分析4)
android·前端·面试
蜡台31 分钟前
vue.config.js 配置
前端·javascript·vue.js·webpack
qq_3813385034 分钟前
微前端架构下的状态管理与通信机制深度解析:从 qiankun 源码到性能优化实战
前端·状态模式
han_43 分钟前
JavaScript设计模式(六):职责链模式实现与应用
前端·javascript·设计模式
网易云音乐技术团队43 分钟前
音乐应该“更好找”:我们为什么在 Agent 时代做了一个音乐 CLI
前端·人工智能
攀登的牵牛花1 小时前
2.1w Star 的 pretext 火在哪?
前端·github
散步去海边1 小时前
Pretext 初识——零 DOM 测量的文本布局引擎
前端
xw-busy-code1 小时前
npm 包管理笔记整理
前端·笔记·npm