Lor*_*ran 5 polyfills internet-explorer-11 reactjs create-react-app
我在这里看到了很多类似的问题,我已经尝试了所有方法,但我不知道为什么仍然没有显示任何内容。
npm install react-app-polyfill
我在 package.json 的生产和开发数组中添加了“ie 11”
将此两行添加import "react-app-polyfill/ie11";
import "react-app-polyfill/stable";到顶部index.js
删除 node_modules 中的 .cache 文件夹
重启应用
但仍然没有在 ie 11 中显示任何内容。
这是我的 package.json
{
"name": "firealarm",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.3.3",
"@testing-library/user-event": "^7.1.2",
"antd": "^3.26.2",
"axios": "^0.19.0",
"core-js": "^3.6.1",
"cors": "^2.8.5",
"jspdf": "^1.5.3",
"jspdf-autotable": "^3.2.11",
"react": "^16.12.0",
"react-app-polyfill": "^1.0.5",
"react-dom": "^16.12.0",
"react-router-dom": "^5.1.2",
"react-scripts": "3.3.0"
},
"scripts": {
"start": "set PORT=3006 && react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
"ie 11",
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"ie 11",
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
Run Code Online (Sandbox Code Playgroud)
我什至删除了 node_modules 文件夹并npm重新安装,但仍然无法正常工作。
更新
我在 IE 11 中收到两条错误消息。
SCRIPT5022: SyntaxError
File: 0.chunk.js, Line: 176128, Column: 38
Run Code Online (Sandbox Code Playgroud)
和
SCRIPT5022: The error you provided does not contain a stack trace.
File: 0.chunk.js, Line: 205780, Column: 64
Run Code Online (Sandbox Code Playgroud)
.
我刚刚在 Edge 浏览器上进行了测试,npm start给出了与您提到的相同的错误,但您说您只想在 ie11 上运行您的应用程序。我这样做了,并通过包装(之后)npm run build提供了它,它工作正常。除非您想在 ie 中进行开发,否则如果您能够在本地 ie 上运行您的应用程序,我想这会有所帮助。servenpm i -g serve
| 归档时间: |
|
| 查看次数: |
6281 次 |
| 最近记录: |