一.router-link切换路由不存入history记录的方法
在做tab切换子路由需求的时候,点击后退键,就会返回上一个子路由,不是很符合实际需求。可以在router-link后面加上关键词replace,就可以实现切换子路由,路径不存入history。点击后退按钮,会直接返回父路由的上一个页面。如果是编程式路由,可以吧$router.push()换成$router.replace()
<router-link to="/reportList/reportListValid"
replace
class="link">有效报告</router-link>
二.在router-link上绑定自定义事件
<router-link @click.native="clickRouterTabValid"
to="/reportList/reportListValid"
replace
class="link">有效报告</router-link>
methods: {
clickRouterTabValid() {
console.log('测试自定义点击事件...');
},
},