【发布时间】:2021-02-18 16:20:30
【问题描述】:
使用nuxt generate 生成项目并以这种方式为_slug 页面创建路由:
generate: {
routes() {
return axios.get('https://mywebsite.xyz/categories').then(res => {
return res.data.data.map(category => {
return '/collections/' + category.id
})
})
},
},
路由生成正常但body为空,可以在这里查看:Website Link
我的 nuxt.config:
export default {
ssr: false,
target: 'static',
router: {
base: '/',
extendRoutes(routes, resolve) {
routes.push({
path: '/collections/:slug',
components: {
default: resolve(__dirname, 'pages/collections'), // or routes[index].component
},
chunkNames: {
modal: 'components/modal'
}
})
},
},
如何生成和html网站一模一样的body?
P.S 忘了提一件重要的事情。我正在使用async fetch 加载数据:
async fetch() {
this.filters.category = this.$route.params.slug;
await this.$store.dispatch('filter/getProducts',
{ Product: Product.filter(this.filters)
});
},
【问题讨论】:
标签: nuxt.js