Vuejs2 如何为VueJS项目设置根/基URL

Vuejs2 如何为VueJS项目设置根/基URL,vuejs2,vue.js,Vuejs2,Vue.js,我已将一个VueJS项目部署到一个类似www.example.com的域中,但是,我想将其移动到一个子文件夹中,以便像www.example.com/v1 如何设置VueJS项目的基本URL或根URL 注意:这与Vue资源的基本URL无关您可以使用baseas/v1/移动所有路由以使基本资源成为/v1/ 应用程序的基本URL。例如,如果在/app/下提供整个单页应用程序,则base应使用值“/app/” 古老的 将所有路由移动到,父路由为/v1: const router = new VueRo

我已将一个
VueJS
项目部署到一个类似
www.example.com
的域中,但是,我想将其移动到一个子文件夹中,以便像
www.example.com/v1

如何设置
VueJS
项目的基本URL或根URL

注意:这与
Vue资源的基本URL无关

您可以使用
base
as
/v1/
移动所有路由以使基本资源成为
/v1/

应用程序的基本URL。例如,如果在/app/下提供整个单页应用程序,则base应使用值“/app/”

古老的 将所有路由移动到,父路由为
/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
        }
      ]
    }
  ]
})
const路由器=新的VueRouter({
路线:[
{路径:“v1”,组件:BaseView,
儿童:[
{
//UserProfile将在BaseView的
//当/v1/配置文件匹配时
路径:“配置文件”,
组件:UserProfile
},
{
//UserPosts将在BaseView的
//当/v1/posts匹配时
路径:“posts”,
组件:UserPosts
}
]
}
]
})

Hmm。不知道这是否是最好的解决方案。没有其他简单的方法?@GijoVarghese您可以在route对象中使用
base
选项,检查我的更新。但是我如何设置基本URL?好的,我已经在router中设置了基本URL。但是在构建index.html文件之后,资源文件并不是以/v1开头的。是的,它似乎不像我预期的那样工作,还不确定。