我正在尝试使用nuxt和Json服务器Fake api server来生成一个静态网站。我只是想使用npm run generate将来自json服务器的数据预填充到静态站点。感谢所有帮助!
<script>
import axios from 'axios'
export default {
async asyncData() {
const { data } = await axios.get('http://localhost:4000/gallery')
return { gallery: data }
}
}
</script>
<template>
<section class="gallery-grid">
<nuxt-link
v-for="i in gallery"
:key="i.id"
:to="'/'+i.id">
<img
:src="['gallery/'] + i.src + ['.jpg']"
:alt="i.title">
</nuxt-link>
</section>
</template>