javascript - Vue.js - vue-router 的基本 URL 是否区分大小写?
问题描述
我有一个使用vue-router
模块的 Vue.js 应用程序。
export default new Router({
base: '/CDP/V2',
mode: 'history',
routes: [
{
path: '/home',
name: 'home',
component: HomeApp
}
]
})
vue-router 的基础是否url
区分大小写?
如果是的话,我怎样才能让它不区分大小写?我想让“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
推荐阅读
- yocto - Yocto:添加 musl 库给出构建错误
- c# - 使用 Xamarin.Forms 中的触发器,当 Entry 控件 IsFocused 变为 true 时如何更改标签文本?
- python - 我是 python 新手,不知道如何为不和谐机器人制作状态更改器
- python - 如何在 sklearn/python 中修复“ValueError: Expected 2D array, got 1D array”?
- javascript - 帆布结算卡
- android - Android 用户在尝试评价我发布的 android 游戏时收到 DF-DFERH-01
- innodb - innodb_flush_log_at_trx_commit 和 sync_binlog 有什么区别?
- reactjs - 我可以将状态值从一个组件导入到 react-Redux 中的另一个组件吗?
- javascript - 添加 angular-daterangepicker javascript 文件时出错
- jquery - 使用javascript函数启动mignific popup