Represents an input box.
Since: 1.0.0
Name | Type | Default Value | Mandatory | Description |
|---|---|---|---|---|
value | string | - | No | Initial content of the input box. |
focus | boolean | false | No | Whether the input box has the focus. |
type | string | text | No | Input type. Valid values:
|
confirm-type | string | done | No | Text displayed on the bottom-right button of the keyboard. This property takes effect only when type is set to text. Valid values:
|
password | boolean | false | No | Whether it is a password. |
placeholder | string | - | No | Placeholder when the input box is empty. |
placeholder-style | string | - | No | Placeholder style. Since: 1.0.9 |
disabled | boolean | false | No | Disabled or not. |
maxlength | number | 140 | No | Maximum input length (-1: no limitation on length). |
bindinput | eventhandle | - | No | Event handler triggered upon keyboard input, with event.detail = {value}. |
bindfocus | eventhandle | - | No | Event handler triggered when the input box gains focus. |
bindblur | eventhandle | - | No | Event handler triggered when the input box loses focus. |
bindconfirm | eventhandle | - | No | Event handler triggered when the confirm button is pressed. |
placeholder-class | string | input-placeholder | No | Placeholder style class. Since: 1.0.9 |
HXML file:
<view class="page-section">
<view class="ascf-cells__title">bindinput obtains the input value in real time: {{inputValue}}</view>
<view class="ascf-cells ascf-cells_after-title">
<view class="ascf-cell ascf-cell_input">
<input class="ascf-input" bindinput="bindKeyInput" placeholder="Synchronize the input to the view"/>
</view>
</view>
</view> JS file:
Page({
data: {
inputValue: "",
},
bindKeyInput(e) {
this.setData({
inputValue: e.detail.value,
});
},
});