如何更改 nuxt.js 路由器以使用自定义路径?

How to change nuxt.js router to use custom path?

对于一个软件开发营销网站,我有 30 多个登录页面,我喜欢将它们保存在 ./pages/landing 文件夹中。因此,显然可以访问 ./pages/landing 中的文件,例如:

www.lorem.com/landing/python-development-experts/
www.lorem.com/landing/java-development-experts/

但我需要从路径中删除 /landing/,并且仍然希望将文件保留在 ./pages/landing 文件夹中,但需要使用以下路径访问文件:

www.lorem.com/python-development-experts/
www.lorem.com/java-development-experts/

请帮忙,谢谢。

你可以延长你的路线结账link

https://github.com/nuxt/nuxt.js/issues/112

也许有帮助! 谢谢!

这是我在 nuxt.config.js

中所做的
router: {
  extendRoutes: (routesIn) => {
    routesIn.forEach((r) => {
      if (r.path.includes('/landing/')) {
        r.path = r.path.replace('/landing', '');
      }
    });
    return routesIn;
  },
},