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()
})
相关推荐
Liamhuo32 分钟前
2.1.7 network-浏览器-前端浏览器数据存储
前端·浏览器
洋葱头_32 分钟前
vue3项目不支持低版本的android,如何做兼容
前端·vue.js
前端小书生41 分钟前
React 组件渲染
前端·react.js
sjd_积跬步至千里1 小时前
CSS实现文字横向无限滚动效果
前端
维他AD钙1 小时前
前端基础避坑:3 个实用知识点的简单用法
前端
journs1 小时前
micro-app微前端styled-components CSSOM模式 应用切换样式丢失问题
前端
呼啦啦小魔仙1 小时前
elpis项目DSL设计分享
前端
李李记1 小时前
别让 “断字” 毁了 Canvas 界面!splitByGrapheme 轻松搞定非拉丁文本换行
前端·canvas
来金德瑞1 小时前
快速掌握 ProseMirror 的核心概念
前端
ygria1 小时前
样式工程化:如何实现Design System
前端·前端框架·前端工程化