解決vue+router路由跳轉不起作用的一項原因
阿新 • • 發佈:2020-07-20
如下所示:
Vue.use(Router) export default new Router({ mode:'history',routes: [ { path: '/',component: Login },{ path: '/login',{ path: '/register',component: Register},{path: '/*',component: NotFound},] })
記得要寫上 mode:'history',原因如下
補充知識:vue-router配置後位址列輸入跳轉不成功問題
在起服務的js中增加 connect-history-api-fallback
const history = require('connect-history-api-fallback'); // 在靜態頁面之前,這一句:app.use('/static',express.static(__dirname + '/public'))之前設定history const historyConfig = { index: '/index.html' }; app.use(history(historyConfig));
以上這篇解決vue+router路由跳轉不起作用的一項原因就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支援我們。