w***@163.com
w***@163.com
  • 发布:2019-10-17 13:07
  • 更新:2019-10-17 16:58
  • 阅读:992

【报Bug】条件编译后面添加"//"注释,导致编译App端出错(H5端正常)

分类:HBuilderX

详细问题描述

当条件编译语句后再添加"//"注释时,例如:

// #ifdef APP-PLUS     //APP支付--->添加这个注释,会引起App端编译出错。                  
alert(应用页面跳转了);  
uni.redirectTo({  
    url: '/pages/money/payResult'  
});  
// #endif

编译APP版本出现如下错误提示,App启动后白屏:
12:24:12.357 项目 'BNIOT_app' 开始编译...
12:24:15.772 编译器版本:2.2.6
12:24:15.777 当前项目编译模式:自定义组件模式。编译模式差异见:https://ask.dcloud.net.cn/article/35843
12:24:15.781 当前nvue编译模式:uni-app 。编译模式差异见:https://ask.dcloud.net.cn/article/36074
12:24:35.706 DONE Build complete. Watching for changes...
12:24:35.706 项目 'BNIOT_app' 编译成功.
12:24:35.723 Module build failed (from ./node_modules/@dcloudio/webpack-uni-mp-loader/lib/script.js):
12:24:35.724 SyntaxError: Unexpected token }
12:24:35.740 at new Function (<anonymous>)
12:24:35.828 at getTestTemplate (C:\Program Files\HBuilderX.2.2.6.20190914-alpha.full\HBuilderX\plugins\uniapp-cli\node_modules\@dcloudio\vue-cli-plugin-uni\packages\webpack-preprocess-loader\preprocess\lib\preprocess.js:375:10)
12:24:35.848 at testPasses (C:\Program Files\HBuilderX.2.2.6.20190914-alpha.full\HBuilderX\plugins\uniapp-cli\node_modules\@dcloudio\vue-cli-plugin-uni\packages\webpack-preprocess-loader\preprocess\lib\preprocess.js:379:16)
12:24:35.866 at C:\Program Files\HBuilderX.2.2.6.20190914-alpha.full\HBuilderX\plugins\uniapp-cli\node_modules\@dcloudio\vue-cli-plugin-uni\packages\webpack-preprocess-loader\preprocess\lib\preprocess.js:174:18
12:24:35.885 at C:\Program Files\HBuilderX.2.2.6.20190914-alpha.full\HBuilderX\plugins\uniapp-cli\node_modules\@dcloudio\vue-cli-plugin-uni\packages\webpack-preprocess-loader\preprocess\lib\preprocess.js:326:22
12:24:35.906 at Array.reduce (<anonymous>)
12:24:35.922 at matchReplacePass (C:\Program Files\HBuilderX.2.2.6.20190914-alpha.full\HBuilderX\plugins\uniapp-cli\node_modules\@dcloudio\vue-cli-plugin-uni\packages\webpack-preprocess-loader\preprocess\lib\preprocess.js:313:20)
12:24:35.924 at replaceRecursive (C:\Program Files\HBuilderX.2.2.6.20190914-alpha.full\HBuilderX\plugins\uniapp-cli\node_modules\@dcloudio\vue-cli-plugin-uni\packages\webpack-preprocess-loader\preprocess\lib\preprocess.js:333:10)
12:24:35.942 at preprocessor (C:\Program Files\HBuilderX.2.2.6.20190914-alpha.full\HBuilderX\plugins\uniapp-cli\node_modules\@dcloudio\vue-cli-plugin-uni\packages\webpack-preprocess-loader\preprocess\lib\preprocess.js:168:10)
12:24:35.962 at Object.preprocess (C:\Program Files\HBuilderX.2.2.6.20190914-alpha.full\HBuilderX\plugins\uniapp-cli\node_modules\@dcloudio\vue-cli-plugin-uni\packages\webpack-preprocess-loader\preprocess\lib\preprocess.js:93:10)
12:24:35.980 at Object.module.exports (C:\Program Files\HBuilderX.2.2.6.20190914-alpha.full\HBuilderX\plugins\uniapp-cli\node_modules\@dcloudio\webpack-uni-mp-loader\lib\script-new.js:34:26)
12:24:35.998 at Object.module.exports (C:\Program Files\HBuilderX.2.2.6.20190914-alpha.full\HBuilderX\plugins\uniapp-cli\node_modules\@dcloudio\webpack-uni-mp-loader\lib\script.js:20:38)
12:24:36.014 ERROR Build failed with errors.
12:24:36.605 正在建立手机连接...
12:24:39.971 正在同步手机端程序文件...
12:24:42.064 同步手机端程序文件完成

(DCloud产品不会有明显的bug,所以你遇到的问题大都是在特定环境下才能重现的问题,请仔细描述你的环境和重现方式,否则DCloud很难排查解决你的问题)

[内容]

重现步骤

[步骤]

[结果]

[期望]

[如果语言难以表述清晰,拍一个视频或截图,有图有真相]

IDE运行环境说明

[HBuilder 或 HBuilderX。如果你用其他工具开发uni-app,也需要在此说明]

[IDE版本号]
HBuilder X 2.2.6.20190914-alpha

[windows版本号]
windows 10
[mac版本号]

uni-app运行环境说明

[运行端是h5或app或某个小程序?]
App端有问题;H5端正常。
[运行端版本号]

[项目是cli创建的还是HBuilderX创建的?如果是cli创建的,请更新到最新版cli再试]
HBuilderX创建
[编译模式是老模板模式还是新的自定义组件模式?]

App运行环境说明

[Android版本号]

[iOS版本号]

[手机型号]

[模拟器型号]

附件

[IDE问题请提供HBuilderX运行日志。菜单帮助-查看运行日志,点右键打开文件所在目录,将log文件压缩成zip包上传]

[App问题请提供可重现问题的代码片段,你补充的细一点,问题就解决的快一点]

[App安装包或H5地址]

[可重现代码片段]

联系方式

wjp1975@163.com
[QQ]

2019-10-17 13:07 负责人:无 分享
已邀请:
DCloud_uniCloud_WYQ

DCloud_uniCloud_WYQ

不支持这种写法

该问题目前已经被锁定, 无法添加新回复