HarmonyOS build根组件不支持使用自定义组件

报错如下

In an '@Entry' decorated component, the 'build' function can have only one root node, which must be a container component. <ArkTSCheck>
  • 1.

错误代码:

@Entry
@Component
struct QuickPrescriptionAddPage {
  build() {
    JKContentLayout()
  }
}
@Component
export struct JKContentLayout {
  build() {
    Column() {

    }
    .backgroundColor($r("app.color.jk_common_bg"))
    .width("100%")
    .height("100%")
  }
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
HarmonyOS
2024-12-26 14:01:46
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
fox280

@Entry装饰的自定义组件,其build()函数下的根节点唯一且必要,且必须为容器组件,请参考官方文档使用:https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/arkts-create-custom-components-V5#build函数

分享
微博
QQ
微信
回复
2024-12-26 17:24:47
相关问题
CustomDialog不支持自定义动画
1192浏览 • 2回复 待解决
HarmonyOS 弱引用不支持自定义对象吗
778浏览 • 1回复 待解决
web组件不支持localstorage
1493浏览 • 1回复 待解决
HarmonyOS RNOH Image组件不支持apng
685浏览 • 1回复 待解决
HarmonyOS 组件是否支持自定义事件
819浏览 • 1回复 待解决
Refresh组件不支持设置nestedScroll属性
2719浏览 • 1回复 待解决
HarmonyOS 自定义组件使用
777浏览 • 1回复 待解决
自定义组件是否支持renderFit属性
2603浏览 • 1回复 待解决
HarmonyOS 自定义组件支持链式调用吗
658浏览 • 1回复 待解决
自定义组件onMeasureSize的使用
1307浏览 • 1回复 待解决
HarmonyOS 定义自定义组件
1036浏览 • 1回复 待解决
提问
该提问已有0人参与 ,帮助了0人