路由不变,页面刷新

1、添加中转页

使用this.$router.replace()跳转页面,再重新跳回来不需要打开中转页,beforeRouteEnter拦截跳回去
中转页路由:

{

path: '/refresh',

component: resolve => require(['@/pages/refresh'], resolve),

meta: {

title: '用于同路由刷新'

}

}

中转页:

export default {

beforeRouteEnter(to, from, next) {

next(vm => {

vm.$router.replace(from.path)

// 跳到该路由页面后,再替换为from.path来源路径

})

}

}

跳转:

this.$router.replace('/refresh')

2、路由参数传递时间戳

// 在路由跳转前添加时间戳

router.beforeEach((to, from, next) => {

to.query.timestamp = new Date().getTime();

next();

});

相关推荐
WeilinerL15 分钟前
泛前端代码覆盖率探索之路
前端·javascript·测试
浮游本尊19 分钟前
React 18.x 学习计划 - 第五天:React状态管理
前端·学习·react.js
-睡到自然醒~24 分钟前
[go 面试] 前端请求到后端API的中间件流程解析
前端·中间件·面试
洛卡卡了32 分钟前
Sentry 都不想接,这锅还让我背?这xx工作我不要了!
前端·架构
咖啡の猫36 分钟前
Vue 实例生命周期
前端·vue.js·okhttp
JNU freshman1 小时前
vue 之 import 的语法
前端·javascript·vue.js
剑亦未配妥1 小时前
Vue 2 响应式系统常见问题与解决方案(包含_demo以下划线开头命名的变量导致响应式丢失问题)
前端·javascript·vue.js
凉柚ˇ1 小时前
Vue图片压缩方案
前端·javascript·vue.js
慧一居士1 小时前
vue 中 directive 作用,使用场景和使用示例
前端
慧一居士1 小时前
vue 中 file-saver 功能介绍,使用场景,使用示例
前端