嘻打
嘻打
  • 发布:2020-10-25 18:25
  • 更新:2022-11-21 17:07
  • 阅读:2572

【报Bug】APP端运行正常,小程序端编译失败 报错TypeError: Property value expected type of string but got null

分类:uni-app

产品分类: uniapp/小程序/微信

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: Win10家庭中文版

HBuilderX类型: 正式

HBuilderX版本号: 2.9.3

第三方开发者工具版本号: RC v1.03.2009301

基础库版本号: 1.0.0

项目创建方式: HBuilderX

操作步骤:

运行到微信小程序开发工具

预期结果:

成功编译运行在微信小程序开发者工具

实际结果:

无法正常编译

bug描述:

APP端运行正常,小程序端编译失败,报错如下

正在编译中...  
18:11:14.018 TypeError: Property value expected type of string but got null  
18:11:14.019     at Object.validate (D:\HBuilderX\plugins\uniapp-cli\node_modules\@babel\types\lib\definitions\utils.js:160:13)  
18:11:14.020     at validateField (D:\HBuilderX\plugins\uniapp-cli\node_modules\@babel\types\lib\validators\validate.js:24:9)  
18:11:14.020     at validate (D:\HBuilderX\plugins\uniapp-cli\node_modules\@babel\types\lib\validators\validate.js:17:3)  
18:11:14.020     at builder (D:\HBuilderX\plugins\uniapp-cli\node_modules\@babel\types\lib\builders\builder.js:38:27)  
18:11:14.020     at Object.StringLiteral (D:\HBuilderX\plugins\uniapp-cli\node_modules\@babel\types\lib\builders\generated\index.js:350:31)  
18:11:14.020     at parseEventByCallExpression (D:\HBuilderX\plugins\uniapp-cli\node_modules\@dcloudio\uni-template-compiler\lib\script\traverse\data\event.js:177:30)  
18:11:14.035     at exprStatements.forEach.exprStatement (D:\HBuilderX\plugins\uniapp-cli\node_modules\@dcloudio\uni-template-compiler\lib\script\traverse\data\event.js:302:15)  
18:11:14.035     at Array.forEach (<anonymous>)  
18:11:14.040     at valuePath.forEach.funcPath (D:\HBuilderX\plugins\uniapp-cli\node_modules\@dcloudio\uni-template-compiler\lib\script\traverse\data\event.js:301:28)  
18:11:14.041     at Array.forEach (<anonymous>)  
18:11:14.041     at parseEvent (D:\HBuilderX\plugins\uniapp-cli\node_modules\@dcloudio\uni-template-compiler\lib\script\traverse\data\event.js:242:15)  
18:11:14.041     at _processEvent (D:\HBuilderX\plugins\uniapp-cli\node_modules\@dcloudio\uni-template-compiler\lib\script\traverse\data\event.js:416:9)  
18:11:14.041     at processEvent (D:\HBuilderX\plugins\uniapp-cli\node_modules\@dcloudio\uni-template-compiler\lib\script\traverse\data\event.js:477:5)  
18:11:14.041     at processes.forEach.process (D:\HBuilderX\plugins\uniapp-cli\node_modules\@dcloudio\uni-template-compiler\lib\script\traverse\data\index.js:34:5)  
18:11:14.041     at Array.forEach (<anonymous>)  
18:11:14.041     at traverseData (D:\HBuilderX\plugins\uniapp-cli\node_modules\@dcloudio\uni-template-compiler\lib\script\traverse\data\index.js:33:13)  
18:11:14.091 TypeError: Property value expected type of string but got null  
18:11:14.091     at Object.validate (D:\HBuilderX\plugins\uniapp-cli\node_modules\@babel\types\lib\definitions\utils.js:160:13)  
18:11:14.091     at validateField (D:\HBuilderX\plugins\uniapp-cli\node_modules\@babel\types\lib\validators\validate.js:24:9)  
18:11:14.091     at validate (D:\HBuilderX\plugins\uniapp-cli\node_modules\@babel\types\lib\validators\validate.js:17:3)  
18:11:14.091     at builder (D:\HBuilderX\plugins\uniapp-cli\node_modules\@babel\types\lib\builders\builder.js:38:27)  
18:11:14.102     at Object.StringLiteral (D:\HBuilderX\plugins\uniapp-cli\node_modules\@babel\types\lib\builders\generated\index.js:350:31)  
18:11:14.102     at parseEventByCallExpression (D:\HBuilderX\plugins\uniapp-cli\node_modules\@dcloudio\uni-template-compiler\lib\script\traverse\data\event.js:177:30)  
18:11:14.102     at exprStatements.forEach.exprStatement (D:\HBuilderX\plugins\uniapp-cli\node_modules\@dcloudio\uni-template-compiler\lib\script\traverse\data\event.js:302:15)  
18:11:14.102     at Array.forEach (<anonymous>)  
18:11:14.102     at valuePath.forEach.funcPath (D:\HBuilderX\plugins\uniapp-cli\node_modules\@dcloudio\uni-template-compiler\lib\script\traverse\data\event.js:301:28)  
18:11:14.102     at Array.forEach (<anonymous>)  
18:11:14.102     at parseEvent (D:\HBuilderX\plugins\uniapp-cli\node_modules\@dcloudio\uni-template-compiler\lib\script\traverse\data\event.js:242:15)  
18:11:14.120     at _processEvent (D:\HBuilderX\plugins\uniapp-cli\node_modules\@dcloudio\uni-template-compiler\lib\script\traverse\data\event.js:416:9)  
18:11:14.120     at processEvent (D:\HBuilderX\plugins\uniapp-cli\node_modules\@dcloudio\uni-template-compiler\lib\script\traverse\data\event.js:477:5)  
18:11:14.120     at processes.forEach.process (D:\HBuilderX\plugins\uniapp-cli\node_modules\@dcloudio\uni-template-compiler\lib\script\traverse\data\index.js:34:5)  
18:11:14.120     at Array.forEach (<anonymous>)  
18:11:14.120     at traverseData (D:\HBuilderX\plugins\uniapp-cli\node_modules\@dcloudio\uni-template-compiler\lib\script\traverse\data\index.js:33:13)  
18:11:32.743 Module build failed (from ./node_modules/@dcloudio/vue-cli-plugin-uni/packages/vue-loader/lib/loaders/templateLoader.js):  
18:11:32.743 Error: Compile failed at pages_depos/list.vue  
18:11:32.743     at compile (D:\HBuilderX\plugins\uniapp-cli\node_modules\@dcloudio\uni-template-compiler\lib\index.js:140:13)  
18:11:32.759     at actuallyCompile (D:\HBuilderX\plugins\uniapp-cli\node_modules\@dcloudio\vue-cli-plugin-uni\packages\@vue\component-compiler-utils\dist\compileTemplate.js:70:96)  
18:11:32.759     at compileTemplate (D:\HBuilderX\plugins\uniapp-cli\node_modules\@dcloudio\vue-cli-plugin-uni\packages\@vue\component-compiler-utils\dist\compileTemplate.js:31:16)  
18:11:32.759     at Object.module.exports (D:\HBuilderX\plugins\uniapp-cli\node_modules\@dcloudio\vue-cli-plugin-uni\packages\vue-loader\lib\loaders\templateLoader.js:46:20)  
18:11:32.759 Module build failed (from ./node_modules/@dcloudio/vue-cli-plugin-uni/packages/vue-loader/lib/loaders/templateLoader.js):  
18:11:32.759 Error: Compile failed at pages_product/order/info.vue  
18:11:32.759     at compile (D:\HBuilderX\plugins\uniapp-cli\node_modules\@dcloudio\uni-template-compiler\lib\index.js:140:13)  
18:11:32.775     at actuallyCompile (D:\HBuilderX\plugins\uniapp-cli\node_modules\@dcloudio\vue-cli-plugin-uni\packages\@vue\component-compiler-utils\dist\compileTemplate.js:70:96)  
18:11:32.777     at compileTemplate (D:\HBuilderX\plugins\uniapp-cli\node_modules\@dcloudio\vue-cli-plugin-uni\packages\@vue\component-compiler-utils\dist\compileTemplate.js:31:16)  
18:11:32.777     at Object.module.exports (D:\HBuilderX\plugins\uniapp-cli\node_modules\@dcloudio\vue-cli-plugin-uni\packages\vue-loader\lib\loaders\templateLoader.js:46:20)  
18:11:32.777  ERROR  Build failed with errors.
2020-10-25 18:25 负责人:无 分享
已邀请:
嘻打

嘻打 (作者)

找到问题了
不要在html组件的@回调方法后面中直接使用JSON.stringify的方法
比如下面的写法是错误的

<depos-card  
                @longpress="  
                    moreListShow = true;  
                    oprDepos = item;  
                "  
                v-for="(item, index) in showList"  
                :key="item.depositoryId"  
                :item="item"  
                @goInfo="$common.goUrl('/pages_depos/info/info', { depositoryId: item.depositoryId, fromInfo: JSON.stringify({ organizationId: organization.organizationId }) })"  
                @goProductList="$common.goUrl('/pages_product/list', { depositoryId: item.depositoryId, mode: 1 })"  
></depos-card>

@goInfo方法需要写到方法里
正确的写法像下面这样


        goInfo(item) {  
            this.$common.goUrl('/pages_depos/info/info', {  
                depositoryId: item.depositoryId,  
                fromInfo: JSON.stringify({ organizationId: _this.organization.organizationId || '' })  
            });  
        },

然后再直接回调goInfo的方法

@goInfo="goInfo"
j***@163.com

j***@163.com

解决了 不能这样写

<tui-form-button background="#f9f9f9" color="#999" borderColor="#999" margin="30rpx 0" @click="priceParse(); $Router.back()">返回</tui-form-button>

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