# PasswordInput ### Intro The PasswordInput component is usually used with [NumberKeyboard](#/en-US/number-keyboard) Component. ### Install ```js import Vue from 'vue'; import { PasswordInput, NumberKeyboard } from 'vant'; Vue.use(PasswordInput); Vue.use(NumberKeyboard); ``` ## Usage ### Basic Usage ```html ``` ```js export default { data() { return { value: '123', showKeyboard: true, }; }, methods: { onInput(key) { this.value = (this.value + key).slice(0, 6); }, onDelete() { this.value = this.value.slice(0, this.value.length - 1); }, }, }; ``` ### Custom length ```html ``` ### Without mask ```html ``` ### Hint Error Use `error-info` prop to set error message. For example, a password error is prompted when entering 6 bits ```html ``` ```js export default { data() { return { value: '123', showKeyboard: true, errorInfo: '', }; }, methods: { onInput(key) { this.value = (this.value + key).slice(0, 6); if (this.value.length === 6) { this.errorInfo = 'Password Mistake'; } else { this.errorInfo = ''; } }, onDelete() { this.value = this.value.slice(0, this.value.length - 1); }, }, }; ``` ## API ### Props | Attribute | Description | Type | Default | | --- | --- | --- | --- | | value | Password value | _string_ | `''` | | info | Bottom info | _string_ | - | | error-info | Bottom error info | _string_ | - | | length | Maxlength of password | _number \| string_ | `6` | | gutter | Gutter of input | _number \| string_ | `0` | | mask | Whether to mask value | _boolean_ | `true` | | focused `v2.1.8` | Whether to show focused cursor | _boolean_ | `false` | ### Events | Event | Description | Arguments | | ----- | -------------------------------- | --------- | | focus | Triggered when input get focused | - |