Home >Web Front-end >JS Tutorial >What should I do if Huawei browser cannot open react?
The solution to the problem that Huawei browser cannot open react: first install babel-polyfill; then introduce babel-polyfill where react is mounted or use configuration items to load polyfill on demand.
The operating environment of this tutorial: windows7 system, react17.0.1 version, Dell G3 computer.
What should I do if Huawei browser cannot open the react page?
Pages written using react can be displayed normally in other browsers, but they appear blank in the built-in browser of Huawei Honor mobile phones.
The solution is as follows:
1. Install babel-polyfill
npm install --save babel-polyfill
2. Where react is mounted, before introducing react, introduce babel-polyfill
import 'babel-polyfill'; import React from 'react' import ReactDOM from 'react-dom' ReactDOM.render( <App/>, document.getElementById('app') )
If the above method does not work, is the babel too high?
After version 7 of babel, it has been abandoned
Use configuration items to load polyfill on demand
Add the following configuration to .babelrc:
{ "presets": [ [ "@babel/preset-env", { "useBuiltIns": "entry", "corejs": 3 } ] ] }
Related recommendations: "react video tutorial"
The above is the detailed content of What should I do if Huawei browser cannot open react?. For more information, please follow other related articles on the PHP Chinese website!