【问题标题】:How to use /foo-:bar route in nuxtjs?如何在 nuxtjs 中使用 /foo-:bar 路由?
【发布时间】:2021-04-04 05:47:11
【问题描述】:

我想在 nuxt 中使用这个路由器 /foo-:bar。我怎样才能实现它。我尝试 pages/foo-_bar.vue 但不工作。

【问题讨论】:

    标签: javascript vue.js nuxt.js nuxtjs


    【解决方案1】:

    这需要一个自定义路由,你可以configure in nuxt.config.js:

    module.exports = {
      router: {
        extendRoutes(routes, resolve) {
          routes.push({
            name: 'foo',
            path: '/foo-:bar',
            component: resolve(__dirname, 'pages/foo-_bar.vue')
          })
        }
      },
    }
    

    【讨论】:

      猜你喜欢
      • 2022-11-04
      • 2018-10-01
      • 2019-10-07
      • 1970-01-01
      • 1970-01-01
      • 2019-08-30
      • 1970-01-01
      • 2011-11-01
      • 2021-11-22
      相关资源
      最近更新 更多