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()
})
相关推荐
全栈老石37 分钟前
手写一个无限画布 #1:坐标系的谎言
前端·canvas
XW01059991 小时前
4-11判断素数
前端·python·算法·素数
J2虾虾1 小时前
Spring Boot中使用@Scheduled做定时任务
java·前端·spring boot
Heo1 小时前
深入React19任务调度器Scheduler
前端·javascript·面试
一枚前端小姐姐1 小时前
Vue3 + Pinia 状态管理,从入门到模块化
前端·vue.js
用户14436183400971 小时前
你不知道的JS上-(九)
前端·javascript
yuki_uix1 小时前
为什么我的 Auth Token 藏在了 Network 面板的 Doc 里?
前端·python·debug
不会敲代码11 小时前
从原子CSS到TailwindCSS:现代前端样式解决方案全解析
前端·css·react.js
Wect1 小时前
LeetCode 102. 二叉树的层序遍历:图文拆解+代码详解
前端·算法·typescript
简离1 小时前
VSCode Git Bash 终端:告别内置vi,直接用VSCode编辑交互内容
前端