解決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’); // 在靜態頁面之前,這一句:app.use(’/static’, express.static(__dirname + ’/public’))之前設置historyconst historyConfig = { index: ’/index.html’};app.use(history(historyConfig));
以上這篇解決vue+router路由跳轉不起作用的一項原因就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持好吧啦網。
相關文章:
