pagination: {
pageSize: 10,
current: 0,
showSizeChanger: true,
showTotal: total => `共 ${total}条`,
total:50
}, //分页
绑定了pagination 属性之后发现total显示不出来,回去看文档发现是要写成一个函数,于是功能基本正常
但是 它一直报错Invalid prop: custom validator check failed for prop “pagination”.
found in
—>
at src/components/list.vue
at src/views/layout.vue
at src/App.vue
我明明定义了所有需要的属性,但是total 一直是undefined,但是我改变页面总数是可以的
于是直接打印了this.pagination ,神奇的是
自己写的属性并赋值了,结果出来是undefined
最后发现 果然还是自己把undefined赋值给了total
this.updateTotal(this.datas.length);
updateTotal(data) {
this.pagination = {
…this.pagination,
total: data.length
}
console.log(data.length)
}
这个是用来更新total 的只要传入一个数组就好了,结果我多写了个length属性
更正为 this.updateTotal(this.datas);
应该是之前都是手写直接赋值,后来才想把它封装成一个方法,改的时候参数没改,居然能运行