在另一个问题中,这是在那里:
this.products = [...document.querySelectorAll('.product')];
Edge将失败,并显示以下错误:
功能预期
但这有效:
var params = ['hello', '', 7];
var other = [ 1, 2, ...params];
为什么不是顶级的工作在Edge(它在Chrome上)?
在另一个问题中,这是在那里:
this.products = [...document.querySelectorAll('.product')];
Edge将失败,并显示以下错误:
功能预期
但这有效:
var params = ['hello', '', 7];
var other = [ 1, 2, ...params];
为什么不是顶级的工作在Edge(它在Chrome上)?
你可以用 Array.from
,从像对象一样的数组生成一个数组。
this.products = Array.from(document.querySelectorAll('.product'));
好吧,看起来Bergi和Felix在正确的轨道上:在这里 文件 在MDN上他们谈论迭代器。
一些内置构造,例如扩展运算符,在引擎盖下使用相同的迭代协议:
所以Array确实有 entries()
一个 nodelist
在Edge中不支持迭代,也不支持迭代。
尼娜的回答是转到的!