如何使用 npm run build 正确获取内部链接的 URL? [英] How to get internal links' URLs right with npm run build?
问题描述
我的应用托管在一个子文件夹中:my_site.com/my_app/
.尽管我使用了一个 vue.config.js
文件来指定我的应用程序在服务器上的路径(publicPath: '/my_app/'
,我的应用程序中的内部链接还是错了:
不是指向 my_site/my_app/destination
,而是指向 my_site/destination
.
如何解决这个问题?
内部链接由Vue路由器处理.
更改 Vue 路由器中的 base
选项应该可以解决您的问题.
https://router.vuejs.org/api/#base>
样品
new VueRouter({基地:'/my_app/',路线: [...]});
My app is hosted in a subfolder: my_site.com/my_app/
. Although I'm using a vue.config.js
file specifying the path of my app on the server (publicPath: '/my_app/'
, the internal links in my app are still wrong:
Instead of pointing to my_site/my_app/destination
they point to my_site/destination
.
How to solve this problem?
the internal links are handled by Vue router.
changing the base
option in Vue router should solve your problem.
https://router.vuejs.org/api/#base
sample
new VueRouter({
base: '/my_app/',
routes: [...]
});
这篇关于如何使用 npm run build 正确获取内部链接的 URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!