8087
8087
  • 发布:2021-08-10 15:49
  • 更新:2021-08-10 15:49
  • 阅读:557

解构赋值引起的编译问题

分类:uni-app

项目组件中一个for循环中用了es6的解构赋值,造成编译为微信小程序失败并报错;

<view v-for="({title, child}, index) in list" :key="index"></view>

报错内容:

TypeError: Property name expected type of string but got null  
15:43:14.352     at validate (D:\HBuilderX\plugins\uniapp-cli\node_modules\@babel\types\lib\definitions\utils.js:160:13)  
15:43:14.357     at Object.validate (D:\HBuilderX\plugins\uniapp-cli\node_modules\@babel\types\lib\definitions\utils.js:229:7)  
15:43:14.357     at validateField (D:\HBuilderX\plugins\uniapp-cli\node_modules\@babel\types\lib\validators\validate.js:24:9)  
15:43:14.363     at validate (D:\HBuilderX\plugins\uniapp-cli\node_modules\@babel\types\lib\validators\validate.js:17:3)  
15:43:14.368     at builder (D:\HBuilderX\plugins\uniapp-cli\node_modules\@babel\types\lib\builders\builder.js:38:27)  
15:43:14.368     at Object.Identifier (D:\HBuilderX\plugins\uniapp-cli\node_modules\@babel\types\lib\builders\generated\index.js:338:31)  
15:43:14.374     at getMemberExpr (D:\HBuilderX\plugins\uniapp-cli\node_modules\@dcloudio\uni-template-compiler\lib\script\traverse\member-expr.js:115:31)  
15:43:14.385     at traverseRenderList (D:\HBuilderX\plugins\uniapp-cli\node_modules\@dcloudio\uni-template-compiler\lib\script\traverse\render-list.js:163:7)  
15:43:14.385     at Object.CallExpression (D:\HBuilderX\plugins\uniapp-cli\node_modules\@dcloudio\uni-template-compiler\lib\script\traverse\visitor.js:194:11)  
15:43:14.392     at NodePath._call (D:\HBuilderX\plugins\uniapp-cli\node_modules\@babel\traverse\lib\path\context.js:55:20)  
15:43:14.393     at NodePath.call (D:\HBuilderX\plugins\uniapp-cli\node_modules\@babel\traverse\lib\path\context.js:42:17)  
15:43:14.398     at NodePath.visit (D:\HBuilderX\plugins\uniapp-cli\node_modules\@babel\traverse\lib\path\context.js:90:31)  
15:43:14.399     at TraversalContext.visitQueue (D:\HBuilderX\plugins\uniapp-cli\node_modules\@babel\traverse\lib\context.js:112:16)  
15:43:14.405     at TraversalContext.visitMultiple (D:\HBuilderX\plugins\uniapp-cli\node_modules\@babel\traverse\lib\context.js:79:17)  
15:43:14.406     at TraversalContext.visit (D:\HBuilderX\plugins\uniapp-cli\node_modules\@babel\traverse\lib\context.js:138:19)  
15:43:14.412     at Function.traverse.node (D:\HBuilderX\plugins\uniapp-cli\node_modules\@babel\traverse\lib\index.js:84:17)  
15:43:14.609 Module build failed (from ./node_modules/@dcloudio/vue-cli-plugin-uni/packages/vue-loader/lib/loaders/templateLoader.js):  
15:43:14.609 Error: Compile failed at components/spec-select/spec-select.vue  
15:43:14.614     at compile (D:\HBuilderX\plugins\uniapp-cli\node_modules\@dcloudio\uni-template-compiler\lib\index.js:140:13)  
15:43:14.614     at actuallyCompile (D:\HBuilderX\plugins\uniapp-cli\node_modules\@dcloudio\vue-cli-plugin-uni\packages\@vue\component-compiler-utils\dist\compileTemplate.js:70:96)  
15:43:14.619     at compileTemplate (D:\HBuilderX\plugins\uniapp-cli\node_modules\@dcloudio\vue-cli-plugin-uni\packages\@vue\component-compiler-utils\dist\compileTemplate.js:31:16)  
15:43:14.619     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)
2021-08-10 15:49 负责人:无 分享
已邀请:

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