Nuxt用双冒号编码/解码URI

vue.js Vue.js

古一梅

2020-03-24

我的网址上有两个冒号。

我将路径推到具有作为其一部分的Nuxt路由器

  export default {
  router: {
    extendRoutes (routes, resolve) {
      routes.push({
        name: 'custom',
        path: 'towns' + '(:[0-9].*)?/',
        component: resolve(__dirname, 'pages/404.vue')
      })
    }
  }
}

例如,当我指向http:// localhost:3000 / towns:3时被翻译为%3A导致该错误消息的URL:

Expected "1" to match ":[0-9].*", but received "%3A2"

如何将其还原为

我徒劳地尝试了encodeURI(),decodeURI(),encodeURIComponent()和decodeURIComponent()。

想要尝试的人的演示:nuxt-extend-routes

欢迎任何建议

第3230篇《Nuxt用双冒号编码/解码URI》来自Winter(https://github.com/aiyld/aiyld.github.io)的站点

0个回答

问题类别

JavaScript Ckeditor Python Webpack TypeScript Vue.js React.js ExpressJS KoaJS CSS Node.js HTML Django 单元测试 PHP Asp.net jQuery Bootstrap IOS Android