- 重写路由的push方法
- 解决,相同路由跳转时,报错
- 利用随机数使其不重复
- 添加,相同路由跳转时,触发watch (仅限string方式传参,形如"view?id=5")
const routerPush = Router.prototype.push Router.prototype.push = function push(location) { if(typeof(location)=="string"){ var Separator = "&"; if(location.indexOf('?')==-1) { Separator='?'; } location = location + Separator + "random=" + Math.random(); } return routerPush.call(this, location).catch(error=> error) }
vue push方法重写解决路由错误问题
最新推荐文章于 2022-12-31 23:10:28 发布