/*! For license information please see 2597.ed86d57e.js.LICENSE.txt */ (self.webpackChunk=self.webpackChunk||[]).push([["2597"],{23010:function(s,n,a){"use strict";a.r(n);var t=a("80681");let e=["innerHTML"];n.default={setup:()=>({html:""}),render:()=>((0,t.wg)(),(0,t.iD)("div",{class:"van-doc-markdown-body",innerHTML:'
The PasswordInput component is usually used with NumberKeyboard Component.
\nRegister component globally via app.use
, refer to Component Registration for more registration ways.
import { createApp } from 'vue';\nimport { PasswordInput, NumberKeyboard } from 'vant';\n\nconst app = createApp();\napp.use(PasswordInput);\napp.use(NumberKeyboard);\n
\n<van-password-input\n :value="value"\n :focused="showKeyboard"\n @focus="showKeyboard = true"\n/>\n<van-number-keyboard\n v-model="value"\n :show="showKeyboard"\n @blur="showKeyboard = false"\n/>\n
\nimport { ref } from 'vue';\n\nexport default {\n setup() {\n const value = ref('123');\n const showKeyboard = ref(true);\n\n return {\n value,\n showKeyboard,\n };\n },\n};\n
\n<van-password-input\n :value="value"\n :gutter="15"\n :focused="showKeyboard"\n @focus="showKeyboard = true"\n/>\n
\n<van-password-input\n :value="value"\n :gutter="10"\n :focused="showKeyboard"\n @focus="showKeyboard = true"\n/>\n
\n<van-password-input\n :value="value"\n :mask="false"\n :focused="showKeyboard"\n @focus="showKeyboard = true"\n/>\n
\nUse info
to set info message, use error-info
prop to set error message.
<van-password-input\n :value="value"\n info="Some tips"\n :error-info="errorInfo"\n :focused="showKeyboard"\n @focus="showKeyboard = true"\n/>\n<van-number-keyboard\n v-model="value"\n :show="showKeyboard"\n @blur="showKeyboard = false"\n/>\n
\nimport { ref, watch } from 'vue';\n\nexport default {\n setup() {\n const value = ref('123');\n const errorInfo = ref('');\n const showKeyboard = ref(true);\n\n watch(value, (newVal) => {\n if (newVal.length === 6 && newVal !== '123456') {\n errorInfo.value = 'Password Mistake';\n } else {\n errorInfo.value = '';\n }\n });\n\n return {\n value,\n errorInfo,\n showKeyboard,\n };\n },\n};\n
\nAttribute | \nDescription | \nType | \nDefault | \n
---|---|---|---|
value | \nPassword value | \nstring | \n\'\' | \n
info | \nBottom info | \nstring | \n- | \n
error-info | \nBottom error info | \nstring | \n- | \n
length | \nMaxlength of password | \nnumber | string | \n6 | \n
gutter | \nGutter of input | \nnumber | string | \n0 | \n
mask | \nWhether to mask value | \nboolean | \ntrue | \n
focused | \nWhether to show focused cursor | \nboolean | \nfalse | \n
Event | \nDescription | \nArguments | \n
---|---|---|
focus | \nEmitted when input is focused | \n- | \n
The component exports the following type definitions:
\nimport type { PasswordInputProps } from 'vant';\n
\nThe component provides the following CSS variables, which can be used to customize styles. Please refer to ConfigProvider component.
\nName | \nDefault Value | \nDescription | \n
---|---|---|
--van-password-input-height | \n50px | \n- | \n
--van-password-input-margin | \n0 var(--van-padding-md) | \n- | \n
--van-password-input-font-size | \n20px | \n- | \n
--van-password-input-radius | \n6px | \n- | \n
--van-password-input-background | \nvar(--van-background-2) | \n- | \n
--van-password-input-info-color | \nvar(--van-text-color-2) | \n- | \n
--van-password-input-info-font-size | \nvar(--van-font-size-md) | \n- | \n
--van-password-input-error-info-color | \nvar(--van-danger-color) | \n- | \n
--van-password-input-dot-size | \n10px | \n- | \n
--van-password-input-dot-color | \nvar(--van-text-color) | \n- | \n
--van-password-input-text-color | \nvar(--van-text-color) | \n- | \n
--van-password-input-cursor-color | \nvar(--van-text-color) | \n- | \n
--van-password-input-cursor-width | \n1px | \n- | \n
--van-password-input-cursor-height | \n40% | \n- | \n
--van-password-input-cursor-duration | \n1s | \n- | \n