组件库文档 tmui.design
键盘 keyboard
键盘组件提供四种模式,可以适应多种输入环境,分别为密码输入,身份证号输入,车牌输入以及常见的数字键盘
因这个组件名字拼错了,现在为了纠正:keyboard和keyborad,两个组件同时存在,可以共用。到了年底错误的组件将删除,请大家做好使用正确组件。
🌶️ 键盘 Keyborad 示例
查看模拟效果+
示例模板
vue
<template>
<tm-app>
<tm-sheet>
<tm-text :font-size="24" _class="font-weight-b" label="基础示例,更多见文档"></tm-text>
<tm-divider></tm-divider>
<tm-radio-group v-model="modeltype">
<tm-radio value="password" label="密码"></tm-radio>
<tm-radio value="card" color="red" label="身份证"></tm-radio>
<tm-radio value="car" color="blue" label="车牌"></tm-radio>
<tm-radio value="number" color="green" label="数字键盘"></tm-radio>
</tm-radio-group>
</tm-sheet>
<tm-cell @click="showdate=true" title="弹出键盘" rightColor="primary" :right-text="dateStr"></tm-cell>
<tm-keyboard decimal :type="modeltype" v-model="dateStr" v-model:show="showdate"></tm-keyboard>
</tm-app>
</template>
<script lang="ts" setup>
import { ref, computed,watch } from "vue"
import { onShow, onLoad } from "@dcloudio/uni-app";
import tmApp from "@/tmui/components/tm-app/tm-app.vue"
import tmSheet from "@/tmui/components/tm-sheet/tm-sheet.vue"
import tmText from "@/tmui/components/tm-text/tm-text.vue"
import tmRadio from "@/tmui/components/tm-radio/tm-radio.vue"
import tmRadioGroup from "@/tmui/components/tm-radio-group/tm-radio-group.vue"
import tmDivider from "@/tmui/components/tm-divider/tm-divider.vue"
import tmCell from "@/tmui/components/tm-cell/tm-cell.vue"
import tmKeyboard from "@/tmui/components/tm-keyboard/tm-keyboard.vue"
const modeltype = ref('password')
const dateStr = ref('')
const showdate = ref(false)
</script>
🌶️ 兼容性
APP-VUE | APP-NVUE | 小程序 | WEB/H5 | VUE3/TS |
---|---|---|---|---|
✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
🌱 参数
本组件含有公共属性 公共属性
参数名 | 类型 | 默认值 | 描述 |
---|---|---|---|
type | String | number | 可选:card 身份证,car 车牌,password 密码,number 数字 |
show | Boolean | false | 是否显示 |
modelValue | String | "" | 输入值v-model |
defaultValue | String | "" | 默认内容 |
color | String | primary | 键盘颜色 |
random | Boolean | false | 是否为随机键盘 |
decimal | Boolean | true | 是否显示小数点(数字键盘有效) |
🌹 事件
事件名 | 参数 | 返回数据 | 描述 |
---|---|---|---|
change | - | modelValue | 返回当前输入内容 |
confirm | - | modelValue | 返回最终输入内容,并隐藏键盘 |
🌽 slot插槽
无
🥗 ref方法
无