feat: add multiple examples (#5564)

This commit is contained in:
木槿花开
2020-01-14 10:15:35 +08:00
committed by neverland
parent c29372b114
commit a530c0314c
12 changed files with 310 additions and 7 deletions
+47
View File
@@ -78,6 +78,53 @@ export default {
/>
```
### Hint Error
Use `error-info` prop to set error message. For example, a password error is prompted when entering 6 bits
```html
<!-- PasswordInput -->
<van-password-input
:value="value"
:error-info="errorInfo"
:focused="showKeyboard"
@focus="showKeyboard = true"
/>
<!-- NumberKeyboard -->
<van-number-keyboard
:show="showKeyboard"
@input="onInput"
@delete="onDelete"
@blur="showKeyboard = false"
/>
```
```javascript
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