Skip to content

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

README.md

PasswordInput

Intro

The PasswordInput component is usually used with NumberKeyboard Component.

Install

import Vue from 'vue';
import { PasswordInput, NumberKeyboard } from 'vant';

Vue.use(PasswordInput).use(NumberKeyboard);

Usage

Basic Usage

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

<!-- NumberKeyboard -->
<van-number-keyboard
  :show="showKeyboard"
  @input="onInput"
  @delete="onDelete"
  @blur="showKeyboard = false"
/>
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

<van-password-input
  :value="value"
  :length="4"
  :gutter="15"
  @focus="showKeyboard = true"
/>

Without mask

<van-password-input
  :value="value"
  :mask="false"
  @focus="showKeyboard = true"
/>

API

Props

Attribute Description Type Default
value Password value string ''
length Maxlength of password number 6
mask Whether to mask value boolean true
info Bottom info string -
error-info Bottom error info string -
gutter Gutter of input `number string`

Events

Event Description Arguments
focus Triggered when input get focused -