【问题标题】:AngularJS 'SCRIPT1002: Syntax error' IE9+ when trying .filterAngularJS 'SCRIPT1002: Syntax error' IE9+ 尝试.filter
【发布时间】:2018-10-31 16:00:31
【问题描述】:

只有在 IE 中加载页面时出现此问题,在 Chrome/FF/Edge 中正常。

我有以下...

 $scope.getOtherInfo = function (appID) {       
        $scope.otherInfo = $scope.applications.filter(e => e.ApplicationId === appID).map(function (el) {
            return ({
                AppID: appID,
                Title: el['Title'].replace(/ /g, '')               
            });
        });
    };

(applications是一个多维数组,此时otherInfo为null)

这在 Chrome 等中运行良好,可以调用它的工作等。在 IE 中,虽然在页面加载时我得到了

SCRIPT1002:语法错误 jsFile.js (98,58)

指向下一行

  $scope.otherInfo = $scope.applications.filter(e => e.ApplicationId === appID).map(function (el) {

我不确定如何进一步分解线路以尝试准确调试它不喜欢的内容。

【问题讨论】:

  • 现在 IE 中有箭头符号。 (使用Babel.js编译你的JS代码)写成.filter(function (e) { return e.ApplicationId === appID; })

标签: angularjs internet-explorer filter


【解决方案1】:

Ie9 不支持箭头函数。 Please check this link for supported browsers:

尝试使用正常的函数方法来执行您的操作。 如果这不起作用,请检查您的页面是否以 Quirks 模式呈现,IE9 支持地图,但很可能您的 html 页面以 Quirks 模式呈现,那就是它失败了。尝试将 doctype 添加到您的页面并检查它是否有效。

【讨论】:

    猜你喜欢
    • 2022-06-24
    • 2022-12-27
    • 2016-10-23
    • 1970-01-01
    • 1970-01-01
    • 2023-01-03
    • 2015-04-24
    • 1970-01-01
    • 2020-05-25
    相关资源
    最近更新 更多