目录

input

输入框。

起始版本:1.0.0

属性

名称

类型

默认值

必填

描述

value

string

-

否

输入框的初始内容。

focus

boolean

false

否

获取焦点。

type

string

-

否

input 的类型,有效值如下:

  • text:文本输入键盘。
  • number:数字输入键盘。

confirm-type

string

done

否

confirm-type的类型,有效值如下:(仅在type='text')时生效。

  • send:右下角按钮为发送。
  • search:右下角按钮为搜索样式。
  • next:右下角按钮为下一步。
  • go:右下角按钮为开始样式。
  • done:右下角按钮为完成。

password

pssword

boolean

否

是否是密码类型。

placeholder

string

  

否

输入框为空时占位符。

disabled

boolean

false

否

是否禁用。

maxlength

number

140

否

最大输入长度,设置为 -1 的时候不限制最大长度。

bindinput

eventhandle

-

否

键盘输入时触发,event.detail = {value}。

bindfocus

eventhandle

-

否

输入框聚焦时触发。

bindblur

eventhandle

-

否

输入框失去焦点时触发。

bindconfirm

eventhandle

-

否

点击完成按钮时触发。

示例

hxml文件

<view class="page-section">
    <view class="ascf-cells__title">bindinput实时获取输入值:{{inputValue}}</view>
    <view class="ascf-cells ascf-cells_after-title">
      <view class="ascf-cell ascf-cell_input">
        <input class="ascf-input"  bindinput="bindKeyInput" placeholder="输入同步到view中"/>
      </view>
    </view>
</view>

js文件

Page({
  data: {
    inputValue: "",
  },
  bindKeyInput(e) {
    this.setData({
      inputValue: e.detail.value,
    });
  },
});