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()
})
相关推荐
lovepenny1 分钟前
Failed to resolve entry for package "js-demo-tools". The package may have ......
前端·npm
超凌9 分钟前
threejs 创建了10w条THREE.Line,销毁数据,等待了10秒
前端
车厘小团子27 分钟前
🎨 前端多主题最佳实践:用 Less Map + generate-css 打造自动化主题系统
前端·架构·less
芒果12531 分钟前
SVG图片通过img引入修改颜色
前端
海云前端144 分钟前
前端面试ai对话聊天通信怎么实现?面试实际经验
前端
一枚前端小能手1 小时前
🔧 半夜被Bug叫醒的痛苦,错误监控帮你早发现
前端
Juchecar1 小时前
Vue 3 单页应用Router路由跳转示例
前端
这人是玩数学的1 小时前
在 Cursor 中规范化生成 UI 稿实践
前端·ai编程·cursor
UncleKyrie1 小时前
🎨 市面上主流 Figma to Code MCP 对比
前端
南半球与北海道#1 小时前
前端引入vue-super-flow流程图插件
前端·vue.js·流程图