【发布时间】:2016-06-28 10:54:35
【问题描述】:
我正在尝试做一个简单的循环:
const parent = this.el.parentElement
console.log(parent.children)
parent.children.forEach(child => {
console.log(child)
})
但我收到以下错误:
VM384:53 Uncaught TypeError: parent.children.forEach 不是函数
即使parent.children 记录:
可能是什么问题?
注意:这是JSFiddle。
【问题讨论】:
-
element.siblings 出现同样的问题
-
@Daut 是,因为 element.siblings 返回一个 HTMLCollection 而 HTMLCollections 没有 forEach() 方法
-
你好,谷歌搜索器!如果您正在阅读这篇文章,请仔细检查它是否是带有大写 E 而不是 foreach 的 forEach ....
标签: javascript ecmascript-6 vue.js