繁体   English   中英

Nuxt.js:`npm run generate` 无法生成 `index.html`

[英]Nuxt.js: `npm run generate` fails to generate `index.html`

生成所有 static 路由和动态路由,但不生成index.html 为什么不?

nuxt-config.js我有:

const staticRoutes =
  [
    '/about',
    '/contact',
    '/portfolio'
  ]
const dynamicRoutes = async () => {
  const routes = await axios.get('https://my-site.com/wp/wp-json/projects/v1/posts')
    .then(res => res.data.map((project) => `/project/${project.ID}/${project.post_name}`))

  return routes
}

您必须编辑您的dynamicRoutes function 以在您的路线中添加索引/ routes

const dynamicRoutes = async () => {
  const routes = await axios.get('https://fabricepallaud.com/wp/wp-json/projects/v1/posts')
    .then(res => res.data.map((project) => `/project/${project.ID}/${project.post_name}`))

  routes.push("/")

  return routes
}

https://github.com/nuxt-community/router-module#using-top-level-options

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM