"类型错误:对象没有´t支持这个未定义的动作“;Angular应用程序IE8中的错误

"TypeError: Object doesn´t support this actionundefined" bug in IE8 with Angular app

本文关键字:错误 未定义 Angular IE8 应用程序 支持 类型 quot 对象 #180      更新时间:2023-09-26

"TypeError:Object不支持此操作undefined"当我尝试执行我的angular应用程序时,这是IE8控制台中的消息。Angular并没有执行它应该执行的任何操作。有人能为解决这个问题提供建议吗?我已经包括了json2和ui ieshiv。我也用这种方式写了html标签:

<html xmlns:ng="http://angularjs.org" class="ng-app:app" ng-app="app" id="ng-app">

祝你一切顺利!

当我在IE8中运行我的angular应用程序时,有3件事是IE8不喜欢的。

1) console.log函数。在angular被引导之前,我不得不把这个javascript放在页面中:

// Avoid `console` errors in browsers that lack a console.
            (function() {
                var method;
                var noop = function () {};
                var methods = [
                    'assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error',
                    'exception', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log',
                    'markTimeline', 'profile', 'profileEnd', 'table', 'time', 'timeEnd',
                    'timeStamp', 'trace', 'warn'
                ];
                var length = methods.length;
                var console = (window.console = window.console || {});
                while (length--) {
                    method = methods[length];
                    // Only stub undefined methods.
                    if (!console[method]) {
                        console[method] = noop;
                    }
                }
            }());

2) toISOString函数

 /*IE8 toISOString hack */
            if (!Date.prototype.toISOString) {
                Date.prototype.toISOString = function() {
                    function pad(n) { return n < 10 ? '0' + n : n }
                    return this.getUTCFullYear() + '-'
                        + pad(this.getUTCMonth() + 1) + '-'
                        + pad(this.getUTCDate()) + 'T'
                        + pad(this.getUTCHours()) + ':'
                        + pad(this.getUTCMinutes()) + ':'
                        + pad(this.getUTCSeconds()) + '.'
                        + pad(this.getUTCMilliseconds()) + 'Z';
                };
            }

3) forEach函数

  /*IE8 hack to support forEach */
            if (!Array.prototype.forEach) {
              Array.prototype.forEach = function(fn, scope) {
                for(var i = 0, len = this.length; i < len; ++i) {
                  fn.call(scope, this[i], i, this);
                }
              }
            }

请注意,这些都不是我自己写的。。我从SO.那里"挖掘"了它

这些都是我为了在IE8中运行而不得不修复的罪魁祸首。现在,它运行良好。

问题解决了我发现IE8和插件Angular Restful之间存在问题。当我把它拿走时,我的应用程序又恢复了工作。