undefined is not iterable (cannot read property Symbol(Symbol.iterator)) at _iterableToArray

undefined is not iterable (cannot read property Symbol(Symbol.iterator)) at _iterableToArray

undefined is not iterable (cannot read property Symbol(Symbol.iterator)) at _iterableToArray

如果报了这个错误,说明你代码中可能用了 es6中的拓展运算符

我的是这样用的

async loadMore() {
    // 获取朋友圈动态
	let response = await this.$api.myCollect()
    this.arr= [...this.arr, ...response.data.Arr];
}

解决方法是: 做个判断

async loadMore() {
    // 获取朋友圈动态
	let response = await this.$api.myCollect()

    if (response.code == 200 && response.data.Arr) {
	    this.arr= [...this.arr, ...response.data.Arr];
    } 
}

原因是 :

... 这三个点,不能作用在undefined的数据上,所以做个判断就可以了

转载请说明出处内容投诉
CSS教程_站长资源网 » undefined is not iterable (cannot read property Symbol(Symbol.iterator)) at _iterableToArray

发表评论

欢迎 访客 发表评论

一个令你着迷的主题!

查看演示 官网购买