Vue.js routes serving from subdirectory

前端 未结 2 1797
刺人心
刺人心 2020-12-15 23:24

I would like to serve my Vue.js app from a subdirectory on a staging server. For example: http://url.com/subdir/app/

Right now if I do this and set up the build con

相关标签:
2条回答
  • 2020-12-15 23:41

    I have been able to solve this, using the base property of vue-route. In the case of the example it would look like this:

    export default new Router({
        mode: 'history',
        base: '/subdir/app/',
        routes: [
        {
            path: '/',
            component: ContentView,
            children: [
    

    My question now is how can I make this subdirectory dynamically. Imagine a single server, and 2 different urls pointing to this server.

    www.dominio / app1
    www.dominio / app2
    
    0 讨论(0)
  • 2020-12-15 23:49

    The assetsPublicPath config is just for webpack assets. For vue-router, you need to set the base option in the constructor.

    See docs: https://router.vuejs.org/en/api/options.html#base

    0 讨论(0)
提交回复
热议问题