目录

Button

The Button component is usually activated by user clicks to perform a specific action. It comes in four types: capsule, circle, normal, and rounded rectangle. When used as a container, the Button component accepts child components such as text and images. For details, see Button.

Creating a Button

You can create a button using the following methods:

Setting the Button Type

Buttons come in four types, set using the type parameter: Capsule, Circle, Normal, and ROUNDED_RECTANGLE.

Setting Styles

Adding Events

The Button component is usually used to trigger actions. You can bind the onClick event to the button to have it respond with custom behavior after being clicked.

Button('Ok', { type: ButtonType.Normal, stateEffect: true })
  .onClick(()=>{
    hilog.info(DOMAIN, 'testTag', 'Button onClick');
  }).margin(10)

Example