nuxt项目如何在路由地址上添加.html后缀?

export default {
  // ...

  router: {
    extendRoutes(routes, resolve) {
      routes.push({
        name: 'test-id-html',
        path: '/test/:id.html',
        component: resolve(__dirname, 'test/_id.vue')
      });

      routes.push({
        name: 'test-html',
        path: '/test.html',
        component: resolve(__dirname, 'test/_id.vue')
      });
    }
  }

  // ...
}

  

nuxt.config.js
...
 router: {
     extendRoutes(routes, resolve) {
         routes.push({
             name: "newsHtml",
             path: "/news/:id.html",
             component: resolve(__dirname, "src/pages/news/id.vue")
         });
    }
  },

  

posted @ 2023-07-19 19:36  慕城蓝就  阅读(329)  评论(0编辑  收藏  举报