[英]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.