是this.list
不是数组?
如果this.list
是类似数组的(length
该对象上必须有一个属性),则应该能够执行以下操作:
Array.prototype.forEach.call(this.list, user => {
// ...
})
要么
Array.from(this.list).forEach(user => {
// ...
})
要么
[...this.list].forEach(user => {
// ...
})
否则,如果this.list
只是一个普通对象,则可以执行以下操作:
Object.keys(this.list).forEach(key => {
const user = this.list[key]
// ...
})
要么
Object.entries(this.list).forEach(([key, user]) => {
// ...
})
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句