vue.js - 如何在vue-router里面使用相对路径?
本文介绍了vue.js - 如何在vue-router里面使用相对路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
用vue写的前端需要部署到Tomcat下面,在导航栏一个按钮的router定义如下:
routes: [{
path: '/DataManager',
component: DataManager,
name: 'DataManager'
}]
如果部署到Tomecat的webapps/Test里面,一开始访问index.html时没有问题,url是:
http://localhost:8080/Test/index.html
但点了按钮后,url就变成了:
http://localhost:8080/DataManager
想让路径为:
http://localhost:8080/Test/DataManager
求教怎么在vue-router里面用相对路径?
解决方案
在router定义里面,注释掉了:
//mode: 'history',
url变成了:
http://localhost:8080/Test/in...
实在搞不定了,就这样吧。
这篇关于vue.js - 如何在vue-router里面使用相对路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文