关于el-table的数据绑定,发生了报错,主要的报错信息如下:
TypeError: Cannot read property ‘offsetHeight’ of null
Cannot read property ‘offsetHeight’ of null
this.$el.querySelectorAll is not a function
1 recursive calls
TypeError: data.reduce is not a function
Cannot read property ‘instance’ of undefined
Error in callback for immediate watcher “data”: “TypeError: data.indexOf is not a function”
原因: :data = param 结果这个param是个对象。示例: vue <el-table :data="image.users" ref="usersRef" border> </el-table>js
image:{ users: { cryptionType: 'sha256', token: '', userList: [ { username: '', password: '', groups: '', remark: '' } ] } }users是一个对象,而:data要绑定一个数组。 我的情况是这边的接口改了,users原本是一个数组,现在变成了一个对象,真正的user数组改到users对象的userList里面去了,但是前端的代码忘了改,导致了这么一个错误。
解决 所以前端代码改成 :data=image.users.userList就正常了。