How to Set Root/Base URL for a VueJS Project

后端 未结 1 1898
时光说笑
时光说笑 2021-01-26 06:04

I\'ve deployed a VueJS project to a domain like www.example.com, however, I want to move it to a subfolder so that I can access it like www.examp

相关标签:
1条回答
  • 2021-01-26 07:06

    You can use option base as /v1/ to move all routes to have base as /v1/.

    The base URL of the app. For example, if the entire single page application is served under /app/, then base should use the value "/app/".

    Old

    How about moving all your routes to nested route, with parent route being /v1:

    const router = new VueRouter({
      routes: [
        { path: 'v1', component: BaseView,
          children: [
            {
              // UserProfile will be rendered inside BaseView's <router-view>
              // when /v1/profile is matched
              path: 'profile',
              component: UserProfile
            },
            {
              // UserPosts will be rendered inside BaseView's <router-view>
              // when /v1/posts is matched
              path: 'posts',
              component: UserPosts
            }
          ]
        }
      ]
    })
    
    0 讨论(0)
提交回复
热议问题