How to get internal links' URLs right with npm

2019-08-17 16:46发布

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条回答
叛逆
2楼-- · 2019-08-17 17:30

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: [...]
});
查看更多
登录 后发表回答