Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/design-patterns/2.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
Knockout.js IE8中抛出错误的索引,我使用的是knockoutjs_Knockout.js_Internet Explorer 8_Indexof - Fatal编程技术网

Knockout.js IE8中抛出错误的索引,我使用的是knockoutjs

Knockout.js IE8中抛出错误的索引,我使用的是knockoutjs,knockout.js,internet-explorer-8,indexof,Knockout.js,Internet Explorer 8,Indexof,从代码看,对象似乎不支持该属性 function _isLabelForDisplayablePrice(label, scope) { var g = self.data.general, checkedPriceVals = g[scope + 'VehicleConfig'].displayablePrices(), priceObjects = g[scope + 'VehicleConfig'].featuredPrices(); for (var i

从代码看,对象似乎不支持该属性

function _isLabelForDisplayablePrice(label, scope) {
    var g = self.data.general,
    checkedPriceVals = g[scope + 'VehicleConfig'].displayablePrices(),
    priceObjects = g[scope + 'VehicleConfig'].featuredPrices();

    for (var i = 0; i < priceObjects.length; i++) {
        // Find the parent object of the label field
        if(label.name() == priceObjects[i].fields.label.name()) {
            // Return true if displayable is checked
            return checkedPriceVals.indexOf(priceObjects[i].fields.displayable.value())  >= 0;
        }
    }

    // should never reach here, but just in case
    return false;
}
function\u IsLabelFordSplayablePrice(标签,范围){
var g=self.data.general,
checkedPriceVals=g[scope+'VehicleConfig']。displayablePrices(),
priceObjects=g[scope+'VehicleConfig'].featuredPrices();
对于(var i=0;i=0;
}
}
//不应该到这里,只是以防万一
返回false;
}
试试这个

    return checkedPriceVals.toString()
.indexOf(priceObjects[i].fields.displayable.value())>=0;

它会起作用。

是使用$.inArray而不是indexOf,或者您可以定义该方法:

if (!Array.prototype.indexOf) {
Array.prototype.indexOf = function (obj, start) {
    for (var i = (start || 0), j = this.length; i < j; i++) {
        if (this[i] === obj) { return i; }
    }
    return -1;
}
}
if(!Array.prototype.indexOf){
Array.prototype.indexOf=函数(obj,start){
对于(var i=(start | | 0),j=this.length;i