跳至主要內容

表单组件_其他常用组件

刘春龙原创...大约 2 分钟WEB前端小程序教程文档

表单是常用的组件,同样,在表单中,也有很多配套的组件

复选框 checkbo

多选项目,与 html 复选框基本一致

<checkbox checked="true" />选中

checked 表示初始状态为选中(true) 或 未选中(false)

配合 checkbox-group 形成一组

<checkbox-group>
  <checkbox checked="true" />
  <text>读书</text>
  <checkbox checked="true" />
  <text>打游戏</text>
  <checkbox />
  <text>听音乐</text>
</checkbox-group>

radio

单选项目,与 html 单选框基本一致

<radio checked="true" />选中

checked 表示初始状态为选中(true) 或 未选中(false)

配合 radio-group 形成一组

<radio-group>
  <radio checked="true" />
  <text>打游戏</text>
  <radio checked="false" />
  <text>读书</text>
  <radio checked="false" />
  <text>听音乐</text>
</radio-group>

label

用来改进表单组件的可用性,与 html 的 label 基本一致

<label for="menu"> <checkbox id="menu" checked="true" />选中 </label>

switch

开关选择器,有着比较美观的展示效果

属性类型默认值必填说明
checkedbooleanfalse是否选中
disabledbooleanfalse是否禁用
typestringswitch样式,有效值:switch, checkbox
colorstring#04BE02switch 的颜色,同 css 的 color
<switch />
<switch checked="true" />
<switch checked="true" disabled />
<switch checked="true" type="checkbox" />
<switch checked="true" color="red" />

textarea

多行输入框,与 html 多行输入框基本一致

属性类型默认值必填说明
valuestring输入框的内容
placeholderstring输入框为空时占位符
disabledbooleanfalse是否禁用
maxlengthnumber140最大输入长度,设置为 -1 的时候不限制最大长度
focusbooleanfalse获取焦点
auto-heightbooleanfalse是否自动增高
<textarea value="文本内容" />
<textarea placeholder="占位符" />
<textarea maxlength="10" />
<textarea disabled />
<textarea focus />
<textarea auto-height />
上次编辑于:
贡献者: 刘春龙
评论
  • 按正序
  • 按倒序
  • 按热度
Powered by Waline v2.15.7