HarmonyOS鸿蒙Next OpenHarmony ETS坑1,@builder BUG(内容显示错误)
HarmonyOS鸿蒙Next OpenHarmony ETS坑1,@builder BUG(内容显示错误)
@Entry
@Component
struct Index {
@Builder
showBug(text:string) {
Column(){
Bug({ text: text })
}
}
@Builder
showNormal(text:string) {
Column(){
Text(text)
.fontSize(30)
}
}
build() {
Column() {
this.showBug("BugA")
this.showBug("BugB")
this.showBug("BugC")
this.showNormal("NormalA")
this.showNormal("NormalB")
this.showNormal("NormalC")
}
}
}
@Component
struct Bug {
@State text:string = '';
build(){
Column(){
Text(this.text)
.fontSize(30)
}
}
}
正确内容显示是BugA、BugB、BugC、NormalA、NormalB、NormalC
更多关于HarmonyOS鸿蒙Next OpenHarmony ETS坑1,@builder BUG(内容显示错误)的实战教程也可以访问 https://www.itying.com/category-93-b0.html
3 回复
楼主您好,已反馈给开发人员,请耐心等待,感谢您的支持
更多关于HarmonyOS鸿蒙Next OpenHarmony ETS坑1,@builder BUG(内容显示错误)的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html
在HarmonyOS鸿蒙Next或OpenHarmony的ETS(Extended TypeScript)开发中,使用@builder
时可能会遇到内容显示错误的BUG。这通常是由于@builder
装饰器在组件渲染时未能正确更新或绑定数据导致的。建议检查以下几点:
- 确保
@builder
函数内的数据绑定正确; - 检查组件状态更新逻辑;
- 确认
@builder
函数是否在每次数据变化时被正确调用。
如果问题依旧,可以尝试使用@State
或@Prop
等装饰器来管理状态,或查阅官方文档获取更多调试信息。