[英]Customize the route prefix pattern using Vue-Router
我正在嘗試使用Vue-Router來模式化我的新項目中的URL,使它們看起來就像現有(非Vue)應用程序中的URL。 現有的應用程序URL如下所示:
/#!page1
/#!page2
我的Vue Router目前看起來像這樣:
const router = new VueRouter({
routes: [
{
path: '/',
redirect: '/page1'
},
{
path: '/page1',
component: Assessments
},
{
path: '/page2',
component: Assessments
}
]
})
但是,當然,這會生成如下所示的URL:
/#/page1
/#/page2
如何配置我的路由器來模仿/#!route
模式?
您可以使用base
選項:
基礎
- type:string
- 默認值:
"/"
應用的基本網址。 例如,如果整個單頁面應用程序在
/app/
,那么base應該使用值"/app/"
。
https://router.vuejs.org/en/api/options.html#base
我已經嘗試過你的情況,它也適用於/#!
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.