我有一个使用vue-router
模块的Vue.js应用程序。
export default new Router({
base: '/CDP/V2',
mode: 'history',
routes: [
{
path: '/home',
name: 'home',
component: HomeApp
}
]
})
vue-router的基础url
是否区分大小写?
如果是,如何使它不区分大小写?我想使“ V2”部分不区分大小写
谢谢
答案 0 :(得分:4)
是的,区分大小写,您可以选中此sample code
,以使其不敏感,请尝试以下代码:
// Define router
const router = new VueRouter({
base: config.basePath,
routes,
mode: 'history'
})
// Route case-sensitivity hotfix
if (router.mode === 'history') {
router.history.getCurrentLocation = function() {
let path = window.location.pathname
let base = router.history.base
// Removes base from path (case-insensitive)
if (base && path.toLowerCase().indexOf(base.toLowerCase()) === 0) {
path = path.slice(base.length)
}
return (path || '/') + window.location.search + window.location.hash
}
}
有关更多详细信息,请检查此issue