解決vue+router路由跳轉不起作用的一項原因
更新時間:2020年07月19日 15:33:15 作者:浪漫的程序猿
這篇文章主要介紹了解決vue+router路由跳轉不起作用的一項原因,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
如下所示:
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', 原因如下

補充知識:vue-router配置后地址欄輸入跳轉不成功問題
在起服務的js中增加 connect-history-api-fallback
const history = require('connect-history-api-fallback');
// 在靜態(tài)頁面之前,這一句:app.use('/static', express.static(__dirname + '/public'))之前設置history
const historyConfig = {
index: '/index.html'
};
app.use(history(historyConfig));
以上這篇解決vue+router路由跳轉不起作用的一項原因就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關文章
Vue?+?ElementUI表格內實現(xiàn)圖片點擊放大效果的兩種實現(xiàn)方式
這篇文章主要介紹了Vue?+?ElementUI表格內實現(xiàn)圖片點擊放大效果的兩種實現(xiàn)方式,第一種使用el-popover彈出框來實現(xiàn)而第二種使用v-viewer插件實現(xiàn),需要的朋友可以參考下2024-08-08
axios全局注冊,設置token,以及全局設置url請求網段的方法
今天小編就為大家分享一篇axios全局注冊,設置token,以及全局設置url請求網段的方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2018-09-09

