openharmony 鸿蒙 js-service-widget-basic-input

2025-06-12 浏览 (1)

input

The <input> component provides a radio button to receive user input.

NOTE

The APIs of this module are supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version.

Attributes

In addition to the universal attributes, the following attributes are supported.

NameTypeDefault ValueMandatoryDescription
typestringradioYesType of the <input> component. Currently, only the radio button is supported.
- radio: a radio button that allows users to select one from multiple others with the same name.
checkedbooleanfalseNoWhether the component is checked or not.
namestring-NoName of the <input> component.
valuestring-NoValue of the <input> component. When type is radio, this attribute is mandatory and the value must be unique for radio buttons with the same name.

Styles

The universal styles are supported.

Events

NameParameterDescription
change$event.checkedItemTriggered when the checked status of a radio button changes. This event returns the value of the selected <input> component.
click-Triggered when the component is clicked.

Example

<!-- xxx.hml -->
<div class="content">
  <input type="radio" checked='true' name="radioSample" value="radio1" onchange="onRadioChange"></input>
  <input type="radio" checked='false' name="radioSample" value="radio2" onchange="onRadioChange"></input>
  <input type="radio" checked='false' name="radioSample" value="radio3" onchange="onRadioChange"></input>
</div>
/* xxx.css */
.content{
  width: 100%;
  height: 200px;
  justify-content: center;
  align-items: center;
}
{
  "actions": {
    "onRadioChange":{
      "action": "message",
      "params": {
        "checkedRadio": "$event.checkedItem"
      }
    }
  }
}

4 x 4 widget

input

你可能感兴趣的鸿蒙文章

harmony 鸿蒙JavaScript Service Widget UI Components

harmony 鸿蒙Data Types

harmony 鸿蒙button

harmony 鸿蒙calendar

harmony 鸿蒙chart

harmony 鸿蒙clock

harmony 鸿蒙divider

harmony 鸿蒙image

harmony 鸿蒙progress

harmony 鸿蒙span

  • 所属分类: 后端技术
  • 本文标签: 鸿蒙 软件
  • 版权声明: 本文链接 https://seaxiang.com/blog/c1LNuR