I get the error SCRIPT1003: Expected ':' i

2019-08-22 15:57发布

问题:

This particular snippet of JS code does not work on IE 11. I get the error SCRIPT1003: Expected ':' and it says it is missing on line that it's in bold.

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

Any ideas? Thank you

回答1:

IE11 does not support shorthand method names. See the compatability part of the MDN. Use

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

(or stop supporting internet exploder, if you have the opportunity to - it causes a lot of headache)