Skip to content

Compose-for-OpenHarmony/HarmonyDom

Repository files navigation

Harmony Dom


Harmony Dom

Harmony Dom is a dom api for OpenHarmony Components.

Install

{
  // ...
  "dependencies": {
    "oh_compose/harmony_dom": "0.1.6"
  }
}

Sample Code

import { BaseNode, ButtonNode, ColumnNode, createNode, TextNode } from '@oh_compose/harmony_dom';

@Entry
@Component
struct Index {

  createDomNode(): BaseNode {
    let rootNode = new ColumnNode()

    let text = new TextNode()
    text.setText("0")

    let button = new ButtonNode()
    button.setText("Add")
    button.onClick(() => {
      let currentCount = Number.parseInt(text.text)
      text.setText(`${currentCount + 1}`)
    })

    rootNode.insert(0, button)
    rootNode.insert(1, text)

    return rootNode
  }

  build() {
    Stack() {
      createUIFromNode(this.createDomNode())
    }
  }
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published