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()
})
相关推荐
Yan.love14 分钟前
【CSS-布局】终极方案:Flexbox 与 Grid 的“降维打击”
前端·css
请叫我聪明鸭1 小时前
基于 marked.js 的扩展机制,创建一个自定义的块级容器扩展,让内容渲染为<div>标签而非默认的<p>标签
开发语言·前端·javascript·vue.js·ecmascript·marked·marked.js插件
悟能不能悟1 小时前
Gson bean getxxx,怎么才能返回给前端
java·前端
2501_944711431 小时前
前端向架构突围系列 - 工程化(五):企业级脚手架的设计与落地
前端·架构
Apex Predator1 小时前
本地库导入到nexus
java·服务器·前端
趁着年轻吃点苦1 小时前
宝塔面板部署指南
前端
0思必得01 小时前
[Web自动化] Selenium中Select元素操作方法
前端·python·selenium·自动化·html
一叶星殇1 小时前
C# .NET 如何解决跨域(CORS)
开发语言·前端·c#·.net
运筹vivo@1 小时前
攻防世界: catcat-new
前端·web安全·php
阿雄不会写代码1 小时前
Let‘s Encrypt HTTPS 证书配置指南
前端·chrome