在发布的另一个问题中,这是存在的:

var a = {};
a.products = [...document.querySelectorAll('.product')];
console.log(a.products);
<div class="product"> </div>


Edge将失败,并显示以下错误:



但是,这是可行的:

    var params = ['hello', '', 7];
    var other = [ 1, 2, ...params];

console.log(params);
console.log(other);


为什么排名靠前的人不能在Edge上使用(Chrome上不能)?

最佳答案

您可以使用 Array.from ,它从类似对象的数组生成一个数组。

this.products = Array.from(document.querySelectorAll('.product'));

09-17 10:37
查看更多