Home >Web Front-end >JS Tutorial >What should I do if Huawei browser cannot open react?

What should I do if Huawei browser cannot open react?

藏色散人
藏色散人Original
2021-02-02 10:01:362397browse

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.

What should I do if Huawei browser cannot open react?

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(&#39;app&#39;)
)

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn