[Vue warn]: Invalid prop: type check failed for prop “tableData”. Expected array, got Promise

控制台打印数组,到第二页的时候没能打印出来,报错信息

报错信息:tableData类型检查失败。 定义的返回结果是Array,但是却得到了Promise  

原先代码:

// 获取后台接口数据
async getList() {
    await fetchList(this.tablePage).then(response => {
    this.tableData = response.data.items
    this.tablePage.total = response.data.total
  })
}

原因是对async await 异步优化成同步不理解,返回结果应是Promise,我在接收数组的时候,是这样的

this.tableData = this.getList()

在调用时,直接this.getList()就行了,获取列表已经在方法内部获取了

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值