Vue router/Element重復點擊導航路由報錯問題及解決
Vue router/Element重復點擊導航路由報錯
雖然此報錯并不會影響項目運行,但是作為一個強迫癥的碼農的確受不了error
解決方法如下
方法1:在項目目錄下運行 npm i vue-router@3.0 -S 將vue-router改為3.0版本即可;
方法2:若不想更換版本解決方法
在router.js中加入以下代碼就可以
記住插入的位置
const originalPush = Router.prototype.push Router.prototype.push = function push(location) { return originalPush.call(this, location).catch(err => err) } // 如果你的改了push還是沒有生效,可以考慮改replace方法 // 修改路由replace方法,阻止重復點擊報錯 const originalReplace = VueRouter.prototype.replace; VueRouter.prototype.replace = function replace(location) { return originalReplace.call(this, location).catch(err => err); };
Vue使用element-UI路由報錯問題
Invalid prop: type check failed for prop "router". Expected Boolean, got String.
prop校驗路由時,要求router是一個boolean類型,但是得到的是一個string類型
官網上router參數(shù)是boolean類型
官網地址: Element - The world's most popular Vue UI framework
報錯代碼
<el-menu router="true" default-active="2" class="el-menu-vertical-demo" text-color="#5F5F60" :collapse="isCollapse" > <el-menu-item index="/library/slider"> <i class="el-icon-menu"></i> <span slot="title">首頁</span> </el-menu-item> </el-menu>
修改方案
1、直接寫router 不要后面的true
<el-menu router default-active="2" class="el-menu-vertical-demo" text-color="#5F5F60" :collapse="isCollapse" > <el-menu-item index="/library/slider"> <i class="el-icon-menu"></i> <span slot="title">首頁</span> </el-menu-item> </el-menu>
2、通過數(shù)據(jù)綁定
<el-menu :router="router" default-active="2" class="el-menu-vertical-demo" text-color="#5F5F60" :collapse="isCollapse" > <el-menu-item index="/library/slider"> <i class="el-icon-menu"></i> <span slot="title">首頁</span> </el-menu-item> </el-menu>
data(){ return { router:true } }
以上為個人經驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關文章
客戶端(vue框架)與服務器(koa框架)通信及服務器跨域配置詳解
本篇文章主要介紹了客戶端(vue框架)與服務器(koa框架)通信及服務器跨域配置詳解,具有一定的參考價值,有興趣的可以了解一下2017-08-08vuex 如何動態(tài)引入 store modules
這篇文章主要介紹了vuex 如何動態(tài)引入 store modules,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2022-03-03vue-cli整合vuex的時候,修改actions和mutations,實現(xiàn)熱部署的方法
今天小編就為大家分享一篇vue-cli整合vuex的時候,修改actions和mutations,實現(xiàn)熱部署的方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2018-09-09