解決vue+router路由跳轉(zhuǎn)不起作用的一項(xiàng)原因
如下所示:
Vue.use(Router)export default new Router({mode:’history’,routes: [ { path: ’/’, component: Login }, { path: ’/login’, component: Login }, { path: ’/register’,component: Register}, {path: ’/*’, component: NotFound}, ]})
記得要寫上 mode:’history’, 原因如下
補(bǔ)充知識(shí):vue-router配置后地址欄輸入跳轉(zhuǎn)不成功問題
在起服務(wù)的js中增加 connect-history-api-fallback
const history = require(’connect-history-api-fallback’); // 在靜態(tài)頁面之前,這一句:app.use(’/static’, express.static(__dirname + ’/public’))之前設(shè)置historyconst historyConfig = { index: ’/index.html’};app.use(history(historyConfig));
以上這篇解決vue+router路由跳轉(zhuǎn)不起作用的一項(xiàng)原因就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. java加載屬性配置properties文件的方法2. PHP正則表達(dá)式函數(shù)preg_replace用法實(shí)例分析3. php redis setnx分布式鎖簡(jiǎn)單原理解析4. CSS3中Transition屬性詳解以及示例分享5. 什么是Python變量作用域6. js select支持手動(dòng)輸入功能實(shí)現(xiàn)代碼7. 如何在PHP中讀寫文件8. 《Java程序員修煉之道》作者Ben Evans:保守的設(shè)計(jì)思想是Java的最大優(yōu)勢(shì)9. bootstrap select2 動(dòng)態(tài)從后臺(tái)Ajax動(dòng)態(tài)獲取數(shù)據(jù)的代碼10. vue使用moment如何將時(shí)間戳轉(zhuǎn)為標(biāo)準(zhǔn)日期時(shí)間格式
