我正在尝试使用vuetify分页组件和nuxt.js构建分页,但它不能与服务器端呈现一起工作。
我使用https://github.com/vuetifyjs/vuetify/issues/4855中的代码添加了nuxt.js链接。它在客户端工作,但在服务器端返回错误"render function or template not defined in component: anonymous“
有谁知道如何建立正确的SSR分页或如何修复我的解决方案?
发布于 2019-04-21 00:13:10
不知道这个线程是否仍然有效,但这是我用nuxt验证分页的解决方案。
<script>
import PostList from "@/components/site/PostList";
import axios from "axios";
export default {
components: {
PostList
},
watchQuery: ["page"],
async asyncData({ $axios, query }) {
try {
const page = query.page || 1;
let { data } = await $axios.get("/articles/?page=" + page);
return {
posts: data.data,
page: data.current_page,
totalPages: data.last_page
};
} catch (e) {
// console.log(e); display errors
}
},
methods: {
next() {
this.$router.push({ query: { page: this.page } });
}
}
};
</script><template>
<v-pagination v-model="page" :length="totalPages" @input="next"></v-pagination>
</template>
https://stackoverflow.com/questions/54531166
复制相似问题