前端vue报错
方法一:给跳转页面script中method gosearch()方法中 治标不治本
通过给push传递成功 失败的回调函数 解决重复跳转到同一个地址
this.$router.push({
name: "search",
params: { keyword: this.keyword},
query: { k: this.keyword.toUpperCase() },
},()=>{},()=>{});
解决路由跳转 重复点击 报错问题 在router文件中index.js中添加以下代码 就可以解决
方法二:推荐
//配置路由的地方
import Vue from 'vue';
import VueRouter from 'vue-router';
// 解决vue-router在3.0版本以上重复点报错问题
//开始添加代码
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
return originalPush.call(this, location).catch(err => err)
}
//代码添加结束
// 使用插件
Vue.use(VueRouter);
// 引入路由组件
import Home from '@/pages/Home'
import Search from &#