vant/docs/examples-docs/en-US/password-input.md
neverland 9084a662c3 [Document] add form components english document (#199)
* [Document] add english document of Checkbox

* [Document] add english document of Field

* [Document] add english document of NumberKeyboard

* [bugfix] NumberKeyboard should not dispaly title when title is empty

* [Document] add english document of PasswordInput

* [Document] add english document of Radio

* [document] add english document of Switch

* [bugfix] remove redundent styles in english document

* [Document] fix details

* fix Switch test cases
2017-10-12 07:06:27 -05:00

1.7 KiB

PasswordInput

The PasswordInput component is usually used with NumberKeyboard Component.

Install

import { PasswordInput, NumberKeyBoard } from 'vant';

Vue.component(PasswordInput.name, PasswordInput);
Vue.component(NumberKeyBoard.name, NumberKeyBoard);

Usage

Basic Usage

:::demo Basic Usage

<!-- PasswordInput -->
<van-password-input
  :value="value"
  info="Some tips"
  @focus="showKeyboard = true"
></van-password-input>

<!-- NumberKeyboard -->
<van-number-keyboard
  :show="showKeyboard"
  @input="onInput"
  @delete="onDelete"
  @blur="showKeyboard = false"
></van-number-keyboard>
export default {
  data() {
    return {
      value: '',
      showKeyboard: true
    }
  },

  methods: {
    onInput(key) {
      this.value = (this.value + key).slice(0, 6);
    },
    onDelete() {
      this.value = this.value.slice(0, this.value.length - 1);
    }
  }
}

:::

API

Attribute Description Type Default Accepted Values
value Password value String '' -
length Maxlength of password Number 6 -
info Bottom info String - -
errorInfo Bottom error info String - -

Event

Event Description Attribute
focus Triggered when input get focused -