您的位置:首頁技術文章
文章詳情頁

解決vue+router路由跳轉不起作用的一項原因

瀏覽:22日期:2023-01-03 11:18:52

如下所示:

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路由跳轉不起作用的一項原因

補充知識: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路由跳轉不起作用的一項原因就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持好吧啦網。

標簽: Vue
相關文章:
国产综合久久一区二区三区