解决vue+router路由跳转不起作用的一项原因

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

解决vue+router路由跳转不起作用的一项原因

浪漫的程序猿   2020-07-19 我要评论

本文着重讲解了解决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'))之前设置history
const historyConfig = {
 index: '/index.html'
};
app.use(history(historyConfig));

以上这篇解决vue+router路由跳转不起作用的一项原因就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们