input

Input box.

Attribute NameTypeDefaultDescriptionMinimum Version
valueStringinitial contents
nameStringcomponent name, used for the form submission of obtained data
typeStringtextinput type, effective value: text, number, digit.
passwordBooleanfalseIs password type or not
placeholderStringplaceholder
placeholder-styleStringspecify placeholder style
placeholder-classStringspecify placeholder style class
disabledBooleanfalsedisable or not
maxlengthNumber140maximum length
focusBooleanfalseget focus
cursorNumberCursor location when specifying focus
onInputEventHandletrigger input event on keyboard entry, event.detail = {value: value}
onConfirmEventHandletrigger on clicking keyboard completion, event.detail = {value: value}
onFocusEventHandletrigger on getting focus, event.detail = {value: value}
onBlurEventHandletrigger on losing focus, event.detail = {value: value}

Screenshot

input

Sample Code

copy
<input placeholder="Here the focus is obtained only when the button below is clicked" focus="{{focus}}" />
<input maxlength="10" placeholder="maximum entered length 10" />
<input onInput="bindKeyInput" placeholder="entry synchronized to view"/>
<input type="number" placeholder="This is a numeral entry box" />
<input password type="text" placeholder="This is a password entry box" />
<input type="digit" placeholder="numeral keyboard with decimal"/>
copy
Page({
  data: {
    focus: false,
    inputValue: '',
  },
  bindButtonTap() {
    this.setData({
      focus: true,
    });
  },
  bindKeyInput(e) {
    this.setData({
      inputValue: e.detail.value,
    });
  },
});