【发布时间】:2017-07-28 14:16:19
【问题描述】:
我已将VueJS 项目部署到www.example.com 之类的域中,但是,我想将其移动到子文件夹中,以便我可以像www.example.com/v1 一样访问它
如何设置VueJS 项目的基本 URL 或根 URL?
注意:这与 Vue-resource 的基本 URL 无关
【问题讨论】:
我已将VueJS 项目部署到www.example.com 之类的域中,但是,我想将其移动到子文件夹中,以便我可以像www.example.com/v1 一样访问它
如何设置VueJS 项目的基本 URL 或根 URL?
注意:这与 Vue-resource 的基本 URL 无关
【问题讨论】:
您可以使用option base 作为/v1/ 将所有路线移动到具有/v1/ 的基础。
应用的基本 URL。例如,如果整个单页应用程序在 /app/ 下提供服务,则 base 应使用值“/app/”。
如何将所有路由移至nested route,父路由为/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
}
]
}
]
})
【讨论】:
base 选项,检查我的更新。