gpt4 book ai didi

javascript - Vue.js - vue-router 的基本 URL 是否区分大小写?

转载 作者:行者123 更新时间:2023-12-03 06:43:53 26 4
gpt4 key购买 nike

我有一个使用 vue-router 的 Vue.js 应用程序模块。

export default new Router({
base: '/CDP/V2',
mode: 'history',
routes: [
{
path: '/home',
name: 'home',
component: HomeApp
}
]
})

是基地 url vue-router 区分大小写?

如果是的话,我怎样才能让它不区分大小写?我想让“V2”部分不区分大小写

谢谢

最佳答案

是的,它区分大小写,您可以查看 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

关于javascript - Vue.js - vue-router 的基本 URL 是否区分大小写?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60470108/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com