Code not running in IE 11, works fine in Chrome

前端 未结 8 1209
春和景丽
春和景丽 2020-12-04 17:16

The following code can be run without a problem in Chrome, but throws the following error in Internet Explorer 11.

Object doesn\'t support property or

相关标签:
8条回答
  • 2020-12-04 17:58

    Follow this method if problem comes when working with angular2+ projects

    I was looking for a solution when i got this error, and it got me here. But this question seems to be specific but the error is not, its a generic error. This is a common error for angular developers dealing with Internet Explorer.

    I had the same issue while working with angular 2+, and it got resolved just by few simple steps.

    In Angular latest versions, there are come commented codes in the polyfills.ts shows all the polyfills required for the smooth running in Internet Explorer versions IE09,IE10 and IE11

    /** IE9, IE10 and IE11 requires all of the following polyfills. **/
    //import 'core-js/es6/symbol';
    //import 'core-js/es6/object';
    //import 'core-js/es6/function';
    //import 'core-js/es6/parse-int';
    //import 'core-js/es6/parse-float';
    //import 'core-js/es6/number';
    //import 'core-js/es6/math';
    //import 'core-js/es6/string';
    //import 'core-js/es6/date';
    //import 'core-js/es6/array';
    //import 'core-js/es6/regexp';
    //import 'core-js/es6/map';
    //import 'core-js/es6/weak-map';
    //import 'core-js/es6/set';
    

    Uncomment the codes and it would work perfectly in IE browsers

    /** IE9, IE10 and IE11 requires all of the following polyfills. **/
    import 'core-js/es6/symbol';
    import 'core-js/es6/object';
    import 'core-js/es6/function';
    import 'core-js/es6/parse-int';
    import 'core-js/es6/parse-float';
    import 'core-js/es6/number';
    import 'core-js/es6/math';
    import 'core-js/es6/string';
    import 'core-js/es6/date';
    import 'core-js/es6/array';
    import 'core-js/es6/regexp';
    import 'core-js/es6/map';
    import 'core-js/es6/weak-map';
    import 'core-js/es6/set';
    

    But you might see a performance drop in IE browsers compared to others :(

    0 讨论(0)
  • 2020-12-04 17:59

    Replace the startsWith function with:

    yourString.indexOf(searchString, position) // where position can be set to 0
    

    This will support all browsers including IE

    Position can be set to 0 for string matching from the start meaning 0th position.

    0 讨论(0)
提交回复
热议问题