【发布时间】:2021-07-05 13:19:52
【问题描述】:
大家好,我相信我们都使用 laravel vue 分页,我过去也使用过,但现在出现错误,不知道为什么。
所以我有我的 getresults 方法
getResults(page = 1) {
axios.get('api/category?page=' + page)
.then(response => {
this.categories = response.data;
});
}
我返回的数据,即类别{}(它是一个对象)
data() {
return {
categories: {},
// Create a new form instance
form: new Form({
id:'',
name: '',
active: ''
}),
}
},
最后是分页
<pagination :data="categories" @pagination-change-page="getResults">
<span slot="prev-nav">< Previous</span>
<span slot="next-nav"> Next ></span>
</pagination>
但出现错误
type check failed for prop "data". Expected Object, got Array
即使它是一个对象,也请需要帮助。谢谢
【问题讨论】:
-
请记录
this.categories = response.data;之后的类别 -
你是这个意思吗?
axios.get('api/category?page=' + page) .then(response => { this.categories = response.data; console.log(categories) }); -
控制台的输出是什么?
-
@BoussadjraBrahim 什么都没有
-
哦,伙计,将其打印为 this.categories 而不是类别