@1o1w1/react-app-polyfill 中文文档教程
react-app-polyfill
这个包包括各种浏览器的 polyfill。 它包括 Create React App 项目使用的最低要求和常用语言功能。
Usage
首先,使用 Yarn 或 npm 安装包:
npm install react-app-polyfill
或者
yarn add react-app-polyfill
Supporting Internet Explorer
您可以导入您打算支持的最小版本的入口点,以确保存在使用 Create React App 所需的最小语言功能。 例如,如果您导入 IE9 入口点,这将包括 IE10 和 IE11 支持。
这些模块确保存在以下语言功能:
Promise
(forasync
/await
support)window.fetch
(a Promise-based way to make web requests in the browser)Object.assign
(a helper required for Object Spread, i.e.{ ...a, ...b }
)Symbol
(a built-in object used byfor...of
syntax and friends)Array.from
(a built-in static method used by array spread, i.e.[...arr]
)
如果您需要更多功能,请参阅下面的Polyfilling 其他语言功能部分。
Internet Explorer 9
// This must be the first line in src/index.js
import 'react-app-polyfill/ie9';
// ...
Internet Explorer 11
// This must be the first line in src/index.js
import 'react-app-polyfill/ie11';
// ...
Polyfilling other language features
您还可以填充目标浏览器中不可用的稳定语言功能。 如果您在 Create React App 中使用它,它会自动使用您定义的 browserslist
在导入 stable
polyfill 时仅包含目标浏览器所需的 polyfill。 如果您需要在您的应用程序中支持 Internet Explorer,请确保遵循上述 Internet Explorer 步骤。
// This must be the first line in src/index.js
import 'react-app-polyfill/stable';
// ...
如果您支持 Internet Explorer 9 或 Internet Explorer 11,则应包括 ie9
或 ie11
和 stable
模块:
对于 IE9:
// These must be the first lines in src/index.js
import 'react-app-polyfill/ie9';
import 'react-app-polyfill/stable';
// ...
对于 IE11:
// These must be the first lines in src/index.js
import 'react-app-polyfill/ie11';
import 'react-app-polyfill/stable';
// ...
react-app-polyfill
This package includes polyfills for various browsers. It includes minimum requirements and commonly used language features used by Create React App projects.
Usage
First, install the package using Yarn or npm:
npm install react-app-polyfill
or
yarn add react-app-polyfill
Supporting Internet Explorer
You can import the entry point for the minimal version you intend to support to ensure that the minimum language features are present that are required to use Create React App. For example, if you import the IE9 entry point, this will include IE10 and IE11 support.
These modules ensure the following language features are present:
Promise
(forasync
/await
support)window.fetch
(a Promise-based way to make web requests in the browser)Object.assign
(a helper required for Object Spread, i.e.{ ...a, ...b }
)Symbol
(a built-in object used byfor...of
syntax and friends)Array.from
(a built-in static method used by array spread, i.e.[...arr]
)
If you need more features, see the Polyfilling other language features section below.
Internet Explorer 9
// This must be the first line in src/index.js
import 'react-app-polyfill/ie9';
// ...
Internet Explorer 11
// This must be the first line in src/index.js
import 'react-app-polyfill/ie11';
// ...
Polyfilling other language features
You can also polyfill stable language features not available in your target browsers. If you're using this in Create React App, it will automatically use the browserslist
you've defined to only include polyfills needed by your target browsers when importing the stable
polyfill. Make sure to follow the Internet Explorer steps above if you need to support Internet Explorer in your application.
// This must be the first line in src/index.js
import 'react-app-polyfill/stable';
// ...
If you are supporting Internet Explorer 9 or Internet Explorer 11 you should include both the ie9
or ie11
and stable
modules:
For IE9:
// These must be the first lines in src/index.js
import 'react-app-polyfill/ie9';
import 'react-app-polyfill/stable';
// ...
For IE11:
// These must be the first lines in src/index.js
import 'react-app-polyfill/ie11';
import 'react-app-polyfill/stable';
// ...
你可能也喜欢
- 1-0-5-hai-aage-dekhte-hein-kya-aat-hai 中文文档教程
- 2e 中文文档教程
- @0xcda7a/npm 中文文档教程
- @0xcert/wanchain-asset-ledger 中文文档教程
- @4geit/rct-data-table-store 中文文档教程
- @4geit/rct-text-selector-component 中文文档教程
- @4geit/swg-message-model 中文文档教程
- @aacassandra/wvue-cli 中文文档教程
- @aaxis/react-native-secure-storage 中文文档教程
- @abbeblubb/react-library 中文文档教程