input
功能描述
文本输入框。
当点击 <form>
表单中 formType 为 submit 的 <button>
组件时,会将表单组件中的 value 值进行提交,需要在表单组件中加上 name 来作为 key。
组件属性
属性名 | 类型 | 默认值 | 说明 |
---|---|---|---|
value | String | 输入框的初始内容 | |
type | String | "text" | input 的类型 |
password | Boolean | false | 是否是密码类型 |
placeholder | String | 输入框为空时占位符 | |
disabled | Boolean | false | 是否禁用 |
maxlength | Number | 140 | 最大输入长度,设置为 -1 的时候不限制最大长度 |
focus | Boolean | false | 获取焦点 |
bindinput | EventHandle | - | 输入框值改变时触发 |
type 有效值:
值 | 说明 |
---|---|
text | 文本输入框 |
password | 密码输入框 |
number | 数字输入框 |
tel | 手机号码输入框 |
digit | 带小数点的数字输入框 |
示例代码
<view class="page-section">
<view class="cells__title">密码输入的input</view>
<view class="cells cells_after-title">
<view class="cell cell_input">
<input class="input“ type=“password" placeholder="这是一个密码输入框" />
</view>
</view>
</view>
<view class="page-section">
<view class="cells__title">控制最大输入长度的input</view>
<view class="cells cells_after-title">
<view class="cell cell_input">
<input class="input" maxlength="10" placeholder="最大输入长度为10" />
</view>
</view>
</view>