DigitalKeyboard 数字键盘
DigitalKeyboard 数字键盘,一般用于数字输入,如金额、密码、验证码输入等。
# 支持平台
| App(vue) | App(nvue) | H5 | 小程序 |
|---|---|---|---|
| ✓ | ✓ | ✓ | ✓ |
# 基础使用
通过 show 属性控制键盘显示隐藏,background 属性设置键盘确定按钮背景色,decimal 属性设置是否显示小数点,spareKey 属性设置备用键文本,theme 属性设置键盘主题。
<wui-digital-keyboard :show="show" :background="background" :decimal="decimal" :spareKey="spareKey" :theme="theme" @click="keyClick" @confirm="confirm" @backspace="backspace" @spare="spare"></wui-digital-keyboard>
const show = ref(false)
const background = ref('')
const decimal = ref(false)
const spareKey = ref('')
const theme = ref('light')
# 自定义插槽内容
通过 zIndex 属性设置元素的堆叠顺序,show 控制键盘显示隐藏,spareKey 属性设置备用键文本,background 属性设置确定按钮背景色。
<wui-digital-keyboard :zIndex="10" :show="visible" spareKey="取消" background="#09BE4F" @click="keyClick"
@confirm="confirm" @backspace="backspace" @spare="spare">
<view class="wui-dk__header">
<text class="wui-title">请输入密码</text>
<wui-single-input :native="false" borderColor="#ccc" border="1" borderWidth="1" radius="16"
activeColor="#09BE4F" cursorHeight="40" cursorColor="#09BE4F" :length="6" width="80" height="80"
size="24" password isFocus :value="value" ref="wui_si">
</wui-single-input>
</view>
</wui-digital-keyboard>
.wui-dk__header {
width: 100%;
padding-bottom: 24rpx;
}
.wui-title {
width: 100%;
display: flex;
justify-content: center;
text-align: center;
font-size: 24rpx;
color: #333;
padding-top: 12rpx;
padding-bottom: 24rpx;
font-weight: normal;
}
# Slots
| 插槽名称 | 说明 |
|---|---|
| default | 键盘上方自定义显示内容 |
# Props
| 属性名 | 类型 | 说明 | 默认值 | 平台差异说明 |
|---|---|---|---|---|
| show | Boolean | 是否显示键盘 | false | - |
| text | String | 确定按钮文本 | 确定 | - |
| background | String | 确定按钮背景色 | #465CFF | 非Nvue端默认为空,可通过css变量(--wui-color-primary)来改变颜色值 |
| color | String | 确定按钮字体颜色 | #fff | - |
| size | Number, String | 确定按钮字体大小,单位rpx | 32 | - |
| fontWeight | Number, String | 确定按钮字重 | 600 | - |
| disabled | Boolean | 是否禁用确定按钮 | false | - |
| name | String | 退格键字体图标名称,可选值: backspace-fill、backspace | backspace-fill | - |
| decimal | Boolean | 是否需要小数点 | false | - |
| spareKey | String | 备用键文本,可变成自己需要的按键,如:取消,清空等 | - | - |
| spareSize | Number, String | 备用键文本字体大小,单位rpx | 32 | - |
| theme | String | 键盘主题,可选值:light、dark | light | - |
| zIndex | Number, String | 键盘的层级z-index值 | 1001 | Nvue端不支持,默认越靠后的元素层级越高 |
| safeArea | Boolean | 是否适配底部安全区 | true | - |
# Events
| 事件名 | 说明 | 回调参数 |
|---|---|---|
| @click | 点击数字键以及小数点键时触发 | { value:按键值 } |
| @backspace | 点击退格键时触发 | - |
| @confirm | 点击确定按钮时触发 | - |
| @spare | 点击备用键时触发(传入备用键文本时可用) | { value:按键文本 } |