HarmonyOS NodeContainer使用方式?

export struct RoomNodeRoot {
  @State nodeController: NodeController | undefined = undefined
  aboutToAppear(): void {
    this.nodeController = new XNodeController(true, this.roomsPageApi!!, this.nodeState)
  }

  build() {
    Stack() {
      if (this.nodeController != undefined) {
        NodeContainer(this.nodeController).width('100%').height('100%').backgroundColor(Color.Transparent)
      }
    }
  }
}

上面这段代码使用的场景是:替换部分功能面板的UI,现在的实现方案是通过替换nodeController实例来做到面板替换,这么实现会不会什么功能问题?

阅读 532
1 个回答

替换nodeController并不会有明显的性能问题,也可以通过Navigation来实现UI局部替换。