H5页面,在安卓7版本中浏览器打开页面为空白?怎么改?
webpack.config.js配置
module: {
rules: [
{
test: /\.m?js$/, // 匹配 .js 或 .mjs 文件
exclude: /node_modules/, // 排除 node_modules 目录(可选,根据实际情况调整)
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env'],
plugins: ['@babel/plugin-transform-runtime'],
}
},
},
{
test: /\.(css|scss|sass)$/i,
use: [
// 'style-loader',
isProduction ? MiniCssExtractPlugin.loader : 'style-loader', // 在开发环境中使用MiniCssExtractPlugin,会影响到webpack 的热更新
'css-loader',
{
loader: 'postcss-loader',
options: {
postcssOptions: {
plugins: [
[
'autoprefixer',
{ /* 自定义选项,如: */
overrideBrowserslist: [
"ie >= 9",
"safari >= 9",
"Android >= 4.4",
"ChromeAndroid >= 4.4",
"iOS >= 5"
],
},
],
],
},
},
},
'sass-loader'
]
},
]}
babel config.json 配置如下:
{
"presets": [
[
"@babel/preset-env",
{
"targets": {
"browsers": [
"ie >= 9",
"safari >= 9",
"Android >= 4.4",
"ChromeAndroid >= 4.4",
"iOS >= 5"
],
"node": "current"
},
"useBuiltIns": "usage",
"corejs": { "version": 3.65, "proposals": true }
}
]
],
"plugins": ["@babel/plugin-transform-runtime"]
// "plugins": ["@babel/plugin-transform-modules-commonjs"],
}
npm install babel-polyfill -S
import “babel-polyfill”