HarmonyOS 鸿蒙Next:Property 'option' has no initializer and is not definitely assigned in the constructor.报错如何解决

发布于 1周前 作者 gougou168 来自 鸿蒙OS

HarmonyOS 鸿蒙Next:Property ‘option’ has no initializer and is not definitely assigned in the constructor.报错如何解决

cke_190.png求助,出现Property ‘option’ has no initializer and is not definitely assigned in the constructor.报错如何解决


关于HarmonyOS 鸿蒙Next:Property ‘option’ has no initializer and is not definitely assigned in the constructor.报错如何解决的问题,您也可以访问:https://www.itying.com/category-93-b0.html 联系官网客服。

2 回复
楼主在做尚学堂 英文单词打卡的案例吧? 我也遇到这个问题 ,这是鸿蒙API升级到12 有更严格的语法约束,声明变量要给默人值:
可以给空

可以初始化

option:string = "";<button style="position: absolute; padding: 4px 8px 0px; cursor: pointer; top: 8px; right: 8px; font-size: 14px;">复制</button>

或者?: 可不存在

option?:string<button style="position: absolute; padding: 4px 8px 0px; cursor: pointer; top: 8px; right: 8px; font-size: 14px;">复制</button>

或者追加类型,并初始化

option:string|undefind = undefind<button style="position: absolute; padding: 4px 8px 0px; cursor: pointer; top: 8px; right: 8px; font-size: 14px;">复制</button>
回到顶部