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

2025-06-12 浏览 (1)

input

交互式组件,提供单选框功能。

说明:

从API Version 8 开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。

属性

除支持通用属性外,还支持如下属性:

名称类型默认值必填描述
typestringradioinput组件类型,当前仅支持radio类型:
- "radio":定义单选按钮,允许在多个拥有相同name值的选项中选中其中一个。
checkedbooleanfalse当前组件是否选中,true表示选中,false表示未选中。
namestring-input组件的名称。
valuestring-input组件的value值,类型为radio时必填且相同name值的选项该值唯一。

样式

支持通用样式

事件

名称参数描述
change$event.checkedItemradio单选框的checked状态发生变化时触发该事件,返回选中的组件value值。
click-点击动作触发该事件。

示例

<!-- 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*4卡片

卡片input

你可能感兴趣的鸿蒙文章

harmony 鸿蒙JS服务卡片UI组件

harmony 鸿蒙数据类型说明

harmony 鸿蒙button

harmony 鸿蒙calendar

harmony 鸿蒙chart

harmony 鸿蒙clock

harmony 鸿蒙divider

harmony 鸿蒙image

harmony 鸿蒙progress

harmony 鸿蒙span

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