RuoYi-Vue 全新 Pro 版本:清除url地址栏路由参数

问题:当前页面保存数据后,要清空当前地址栏的参数。

页面A开始跳转到B

复制代码
//页面A跳转
  this.$router.push({
        path: "你的path",
        query: {
          id: id,
        },
      });

页面B开始接收数据

复制代码
//页面B,在你需要的地方进行接收
this.$route.query.id
当点击保存后,开始清空url
复制代码
//简写
  this.$router.replace({ query: {} });

const query = { ...this.$route.query };

if (query.id) {
      delete query.id;
   //$router.replace() 方法更新路由,但不改变浏览历史
      this.$router.replace({ query });
}

两个方法都可以。

相关推荐
Timer@9 小时前
LangChain 教程 04|Agent 详解:让 AI 学会“自己干活“
javascript·人工智能·langchain
阿珊和她的猫9 小时前
TypeScript中的never类型: 深入理解never类型的使用场景和特点
javascript·typescript·状态模式
skywalk816310 小时前
Kotti Next的tinyfrontend前端模仿Kotti 首页布局还是不太好看,感觉比Kotti差一点
前端
RopenYuan11 小时前
FastAPI -API Router的应用
前端·网络·python
走粥12 小时前
clsx和twMerge解决CSS类名冲突问题
前端·css
Purgatory00112 小时前
layui select重新渲染
前端·layui
weixin1997010801613 小时前
《中国供应商商品详情页前端性能优化实战》
前端·性能优化
九皇叔叔13 小时前
003-SpringSecurity-Demo 统一响应类
java·javascript·spring·springsecurity