Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/443.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript TypeError:property Array.prototype.splice.call(…)是不可配置的,可以';不能删除_Javascript_Prototypejs - Fatal编程技术网

Javascript TypeError:property Array.prototype.splice.call(…)是不可配置的,可以';不能删除

Javascript TypeError:property Array.prototype.splice.call(…)是不可配置的,可以';不能删除,javascript,prototypejs,Javascript,Prototypejs,当我尝试在FF中加载我的页面时,出现以下错误: TypeError: property Array.prototype.splice.call(...) is non-configurable and can't be deleted 这是原型 HTMLElement.prototype.selectorAll = function (selectors, fun) { var sels = Array.prototype.splice.call(this.queryS

当我尝试在FF中加载我的页面时,出现以下错误:

TypeError: property Array.prototype.splice.call(...) is non-configurable and can't be deleted
这是原型

   HTMLElement.prototype.selectorAll = function (selectors, fun) {

        var sels = Array.prototype.splice.call(this.querySelectorAll(selectors), 0)
        if (!fun) { return sels; }; fun.call(sels);
    };
如何修复此错误?

使用而不是仅从原始集合创建新的
数组

var sels = Array.prototype.slice.call(this.querySelectorAll(selectors), 0)
该错误是因为
splice
还试图修改原始集合:

var a = [ 1, 2, 3, 4 ];

a.slice(0);
console.log(a); // [ 1, 2, 3, 4 ]

a.splice(0);
console.log(a); // []

querySelectorAll()
返回的
NodeList
有一个不可配置的属性,
splice
无法按预期更改。

谢谢!修好了!