我正在通过WebView在React Native内部运行React Web应用程序。
该网站使用Object.fromEntries,这似乎不适用于我正在使用的设备上的浏览器,并导致我的webapp崩溃(没有错误),当我尝试调用Object.fromEntries
。
该设备运行的是Android 8.1.0,所以我认为它将使用一个不支持Object.fromEntries
的旧Android浏览器。
在我的网络应用程序babel配置中,我试图针对Android 8.0,但当调用Object.fromEntries
时,应用程序仍然崩溃。
{
"presets": [
[
"@babel/preset-env",
{
"loose": true,
"modules": false,
"shippedProposals": true,
"targets": {
"Android": "8.0",
"browsers": ["last 2 version"]
}
}
],
[
"@babel/preset-react",
{
"useBuiltIns": true,
"pragma": "React.createElement"
}
],
"@babel/preset-typescript"
],
"plugins": [
[
"@babel/plugin-proposal-class-properties",
{
"loose": true
}
],
"@babel/plugin-syntax-dynamic-import",
"babel-plugin-macros",
[
"@babel/plugin-transform-runtime",
{
"helpers": true,
"regenerator": true
}
]
]
}
我需要在Babel配置中包含其他东西吗?或者可能是覆盖它的东西(即Typescript)?
1条答案
按热度按时间polkgigr1#
我在Android 8 Chrome浏览器中加载网页时也遇到了类似的问题。以下两个更改帮助我解决了这个问题:
1.手动添加多边形填充
添加依赖项
然后,在应用的根目录(
index.js
)添加以下两个导入:2.更改生成目标
我使用的是
create-react-app
,并没有直接配置babel,因此这对您来说可能会有所不同,但是我将browserslist
设置更改为(This可能根本不需要)