Javascript Vue.js-Vue路由器的基本url是否区分大小写?

Javascript Vue.js-Vue路由器的基本url是否区分大小写?,javascript,vue.js,vuejs2,vue-component,vue-router,Javascript,Vue.js,Vuejs2,Vue Component,Vue Router,我有一个Vue.js应用程序,它使用Vue路由器模块 vue路由器的基本url是否区分大小写 如果是,我如何使它不区分大小写?我想使V2部件不区分大小写 谢谢是的,它区分大小写,您可以检查它,为了使其不区分大小写,请尝试以下代码: // Define router const router = new VueRouter({ base: config.basePath, routes, mode: 'history' }) // Route case-sensitivity hot

我有一个Vue.js应用程序,它使用Vue路由器模块

vue路由器的基本url是否区分大小写

如果是,我如何使它不区分大小写?我想使V2部件不区分大小写


谢谢

是的,它区分大小写,您可以检查它,为了使其不区分大小写,请尝试以下代码:

// 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
  }
}
有关更多详细信息,请查看此

// 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
  }
}