Angular 2: Check whether user's browser is compatible

前端 未结 2 770
再見小時候
再見小時候 2021-02-07 03:45

I\'m writing an Angular 2 app but am conscious that some users may not be using a browser that can support Angular 2.

I have a check for whether Javascript is enabled, I

2条回答
  •  执笔经年
    2021-02-07 04:08

    Not all browsers fully support ES6 (ES2015) standard yet.

    https://kangax.github.io/compat-table/es6/

    If you want to use ES6 language features for your Angular 2 app then you should include the ES6 shim to bring your browser up-to-spec:

    https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.35.0/es6-shim.min.js

    That being said, IE seems to be the exception. There are additional polyfills that you need to include to support IE:

    https://npmcdn.com/angular2/es6/dev/src/testing/shims_for_IE.js

    If you want to target ES5 (older standard), you need to ensure that you write your angular app using ES5 language features only. In general, there is more browser support for ES5 features, but it's not perfect:

    http://kangax.github.io/compat-table/es5/

    Of course, there's a shim for that too:

    https://cdnjs.cloudflare.com/ajax/libs/es5-shim/4.5.8/es5-shim.min.js

提交回复
热议问题