How to get internal links' URLs right with npm run build?

倾然丶 夕夏残阳落幕 提交于 2019-12-25 02:22:28

问题


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?


回答1:


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: [...]
});


来源:https://stackoverflow.com/questions/56199833/how-to-get-internal-links-urls-right-with-npm-run-build

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!