Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.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 敲除不计算IE7中的表达式_Javascript_Internet Explorer_Knockout.js_Internet Explorer 7 - Fatal编程技术网

Javascript 敲除不计算IE7中的表达式

Javascript 敲除不计算IE7中的表达式,javascript,internet-explorer,knockout.js,internet-explorer-7,Javascript,Internet Explorer,Knockout.js,Internet Explorer 7,当我在Mozilla中运行我的程序时,它解析敲除表达式并在可观察数组中显示值。当我在IE7中执行同样的操作时,它会显示淘汰代码 Mozilla结果 value 1 value 2 value 3 IE7结果 function observable() { if (arguments.length > 0) { // Write // Ignore writes if the value hasn't changed if ((!ob

当我在Mozilla中运行我的程序时,它解析敲除表达式并在可观察数组中显示值。当我在IE7中执行同样的操作时,它会显示淘汰代码

Mozilla结果

value 1
value 2
value 3
IE7结果

function observable() { 
   if (arguments.length > 0) {
        // Write
        // Ignore writes if the value hasn't changed
        if ((!observable['equalityComparer']) || !observable['equalityComparer'](_latestValue, arguments[0])) {
            observable.valueWillMutate();
            _latestValue = arguments[0];
            if (DEBUG) observable._latestValue = _latestValue;
            observable.valueHasMutated();            
        }
        return this; // Permits chained assignments        
   }        
   else {
        // Read
        ko.dependencyDetection.registerDependency(observable); // The caller only needs to be notified of changes if they did a "read" operation
        return _latestValue;       
   }
}

如何在IE7中正确执行此操作?

IE浏览器不支持数组的indexOf,这会导致knockout.js framework出现问题

添加以下javascript,它可能会解决您的问题:

    //
    // IE browsers do not support indexOf method for an Array. Hence 
    // we add it below after performing the check on the existence of
    // the same.
    //
    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;
        };
    }
//
//IE浏览器不支持数组的indexOf方法。因此
//我们在检查是否存在后,将其添加到下面
//同样的。
//
if(!Array.prototype.indexOf)
{
Array.prototype.indexOf=函数(obj,start)
{
对于(var i=(start | | 0),j=this.length;i
您可以分享您的代码或JSFIDLE吗?您在这里发布的内容看起来像是淘汰版js代码。。。你确定这是你的代码引发错误吗?