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()
})
相关推荐
Freedom风间4 小时前
前端优秀编码技巧
前端·javascript·代码规范
萌萌哒草头将军5 小时前
🚀🚀🚀 Openapi:全栈开发神器,0代码写后端!
前端·javascript·next.js
萌萌哒草头将军5 小时前
🚀🚀🚀 Prisma 爱之初体验:一款非常棒的 ORM 工具库
前端·javascript·orm
拉不动的猪5 小时前
SDK与API简单对比
前端·javascript·面试
runnerdancer5 小时前
微信小程序蓝牙通信开发之分包传输通信协议开发
前端
山海上的风6 小时前
Vue里面elementUi-aside 和el-main不垂直排列
前端·vue.js·elementui
电商api接口开发6 小时前
ASP.NET MVC 入门指南二
前端·c#·html·mvc
亭台烟雨中6 小时前
【前端记事】关于electron的入门使用
前端·javascript·electron