【问题标题】:I get the error SCRIPT1003: Expected ':' in IE 11; (Java Script Code error)我收到错误 SCRIPT1003: Expected ':' in IE 11; (Java 脚本代码错误)
【发布时间】:2017-10-09 16:35:13
【问题描述】:

这个特殊的 JS 代码 sn-p 在 IE 11 上不起作用。我收到错误 SCRIPT1003: Expected ':' 并且它说它在粗体字显示在线缺失。

var $actions = application.service('$actions', [
function() {
    let _logout = function() {
        $('#logoutForm').submit();
    }
    return {
        **Logout() {**
            _logout();
        },
    };
}]);

有什么想法吗?谢谢

【问题讨论】:

  • **Logout() {** 那个是谁和}, 那个?
  • ** 文本周围的文本应该加粗,但没有。

标签: javascript angularjs internet-explorer internet-explorer-9 internet-explorer-11


【解决方案1】:

IE11 不支持速记方法名称。请参阅MDN 的兼容性部分。使用

return {
   Logout: function() {
       _logout();
   }
};

(或者停止支持 internet explorer,如果你有机会 - 它会引起很多头痛)

【讨论】:

  • 非常感谢您的回复。你的建议解决了这个问题。我希望我们可以告诉客户停止使用 IE,但我们不能。我喜欢“Exploder”这个名字。
  • ie11 有 babel polyfill 吗?
  • @DimitriKopriwa 我不认为“polyfill”是正确的,因为它是语法糖。但是,如果 babel 设置为发出 ES5 或更低版本,it should do the conversion(IE 无论如何都不支持 ES6)
猜你喜欢
  • 1970-01-01
  • 2020-06-26
  • 2016-09-06
  • 1970-01-01
  • 2020-07-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多