HbuilderX最新版本运行安卓低版本5.1白屏问题
- Dominant language
- JavaScript
- Stars
- 41.6k
- Forks
- 3.7k
- Avg merge
- 7h 6m
- Merged PRs (30d)
- 6
Description
**问题描述**
Mac用Hbuilder4.0.8和Hbuilder5.24版本运行同一个项目代码,4.0.8正常运行,5.24运行报错Uncaught SyntaxError: Use of const in strict mode. at app-view.js:633 ,真机白屏!
**代码报错片段**
13:39:06.567 App Launch at App.vue:4
13:39:06.574 App Show at App.vue:7
13:39:07.567 Uncaught SyntaxError: Use of const in strict mode. at app-view.js:633 [AI修复]
13:39:28.248 App Hide at App.vue:10
13:39:32.233 App Show at App.vue:7
**Ai修复排查结果**
[排查问题]:@dcloudio/vue-cli-plugin-uni 编辑问题:
Android 控制台错误已修复。最新复检日志里只剩正常启动信息,SyntaxError 已消失。
这次根因还是 HBuilderX 5.24 内置 uni-app 编译链给 app-view.js 生成了 Android 视图层不兼容的 ES6 语法,不是你项目业务代码的问题。我修了两处本机编译器文件里的兼容性写法:
/Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/@dcloudio/vue-cli-plugin-uni/packages/app-vue-style-loader/lib/addStylesClient.js
/Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/@dcloudio/uni-cli-shared/lib/style.js
处理内容很窄,只做了语法降级:
const 改成 var
模板字符串改成字符串拼接
对象属性简写改成完整写法
当前结果:
之前报错:Use of const in strict mode
之后报错:Unexpected token ILLEGAL
之后报错:Unexpected token ,
现在:无 Android 控制台语法错误
**预期结果**
修复Bug
Contributor guide
Research direction
Start by reproducing the white screen on Android 5.1 with HBuilderX 5.24 and compare it with 4.0.8. Inspect addStylesClient.js and style.js in the reported uni-app compiler paths, then verify that the generated app-view.js contains no incompatible syntax and that the app starts without the reported console error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- build-system, mobile-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100