uni-app 华为 mate 20 打了自定义包同步上去报 require is not defined
uni-app 华为 mate 20 打了自定义包同步上去报 require is not defined
reportJSException >>>> exception function:createInstanceContext, exception:white screen cause create instanceContext failed,check js stack ->Uncaught ReferenceError: require is not defined
3 回复
你好,问题有解决吗,我也遇到了一样的问题
这个报错是因为华为 mate 20 等部分 Android 设备在 WebView 内核版本较低时,不支持 CommonJS 的 require 语法。uni-app 在自定义打包时,默认会将模块转换为 CommonJS 格式,导致在低版本 WebView 中运行时报错。
解决方案:
- 修改打包配置:
在
manifest.json中配置使用es模块格式:{ "app-plus": { "modules": { "es": true } } }


