NumberKeyboard 数字键盘
一般用于密码,验证码或支付金额输入等金融场景
引入
import { NumberKeyboard } from 'mand-mobile'
Vue.component(NumberKeyboard.name, NumberKeyboard)
代码演示
基本
有确认键和小数点,一般用于价格或金额输入
<template>
<div class="md-example-child md-example-child-number-keyboard md-example-child-number-keyboard-0">
<md-button @click="isKeyBoardShow = !isKeyBoardShow">{{ isKeyBoardShow ? '收起键盘' : '唤起键盘' }}</md-button>
<md-number-keyboard
v-model="isKeyBoardShow"
@enter="onNumberEnter"
@delete="onNumberDelete"
></md-number-keyboard>
<div class="md-example-display" v-show="isKeyBoardShow" v-text="number"></div>
</div>
</template>
<script>
import {NumberKeyboard, Button} from 'mand-mobile'
export default {
name: 'number-keyboard-demo',
components: {
[Button.name]: Button,
[NumberKeyboard.name]: NumberKeyboard,
},
data() {
return {
isKeyBoardShow: false,
number: '',
}
},
methods: {
onNumberEnter(val) {
this.number += val
},
onNumberDelete() {
if (this.number === '') {
return
}
this.number = this.number.substr(0, this.number.length - 1)
},
},
}
</script>
<style lang="stylus" scoped>
.md-example-display
position fixed
top 30%
left 50%
z-index 9999
transform translate(-50%, -50%)
font-size font-heading-large * 2
text-shadow 0 4px 20px color-text-minor
</style>
数字键乱序
<template>
<div class="md-example-child md-example-child-number-keyboard md-example-child-number-keyboard-1">
<md-button @click="isKeyBoardShow = !isKeyBoardShow">{{ isKeyBoardShow ? '收起键盘' : '唤起键盘' }}</md-button>
<md-number-keyboard
v-model="isKeyBoardShow"
ok-text="支付"
disorder
@enter="onNumberEnter"
@delete="onNumberDelete"
></md-number-keyboard>
<div class="md-example-display" v-show="isKeyBoardShow" v-text="number"></div>
</div>
</template>
<script>
import {NumberKeyboard, Button} from 'mand-mobile'
export default {
name: 'number-keyboard-demo',
components: {
[Button.name]: Button,
[NumberKeyboard.name]: NumberKeyboard,
},
data() {
return {
isKeyBoardShow: false,
number: '',
}
},
methods: {
onNumberEnter(val) {
this.number += val
},
onNumberDelete() {
if (this.number === '') {
return
}
this.number = this.number.substr(0, this.number.length - 1)
},
},
}
</script>
<style lang="stylus" scoped>
.md-example-display
position fixed
top 30%
left 50%
z-index 9999
transform translate(-50%, -50%)
font-size font-heading-large * 2
text-shadow 0 4px 20px color-text-minor
</style>
简单类型
无确认键和小数点,一般用于密码或验证码输入
<template>
<div class="md-example-child md-example-child-number-keyboard md-example-child-number-keyboard-1">
<md-button @click="isKeyBoardShow = !isKeyBoardShow">{{ isKeyBoardShow ? '收起键盘' : '唤起键盘' }}</md-button>
<md-number-keyboard
v-model="isKeyBoardShow"
ok-text="支付"
type="simple"
@enter="onNumberEnter"
@delete="onNumberDelete"
></md-number-keyboard>
<div class="md-example-display" v-show="isKeyBoardShow" v-text="number"></div>
</div>
</template>
<script>
import {NumberKeyboard, Button} from 'mand-mobile'
export default {
name: 'number-keyboard-demo',
components: {
[Button.name]: Button,
[NumberKeyboard.name]: NumberKeyboard,
},
data() {
return {
isKeyBoardShow: false,
number: '',
}
},
methods: {
onNumberEnter(val) {
this.number += val
},
onNumberDelete() {
if (this.number === '') {
return
}
this.number = this.number.substr(0, this.number.length - 1)
},
},
}
</script>
<style lang="stylus" scoped>
.md-example-display
position fixed
top 30%
left 50%
z-index 9999
transform translate(-50%, -50%)
font-size font-heading-large * 2
text-shadow 0 4px 20px color-text-minor
</style>
API
NumberKeyboard Props
属性 | 说明 | 类型 | 默认值 | 备注 |
---|---|---|---|---|
v-model | 键盘是否展示 | Boolean | false | - |
is-view | 是否内嵌在页面内展示,否则以弹层形式 | Boolean | false | - |
type | 键盘类型 | String | professional | professional 有确认键和小数点常用于价格或金额输入,simple 一般用于密码或验证码输入 |
disorder | 键盘数字键是否乱序 | Boolean | false | - |
ok-text | 键盘确认键文案 | String | 确认 | - |
NumberKeyboard Methods
show()
展示键盘
hide()
隐藏键盘
NumberKeyboard Events
@enter(val)
数字键点击事件
属性 | 说明 | 类型 |
---|---|---|
val | 数字 | Number |
@delete()
回退键点击事件
@confirm()
确认键点击事件