fs-keyboard.vue 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <template>
  2. <view>
  3. <keyboardCar
  4. v-if="mode === 'car'"
  5. :index="index"
  6. v-model="visible"
  7. @change="handleChange"
  8. @close="handleClose"
  9. ></keyboardCar>
  10. <keyboardNum
  11. v-if="mode === 'number'"
  12. :index="index"
  13. v-model="visible"
  14. @change="handleChange"
  15. @close="handleClose"
  16. />
  17. </view>
  18. </template>
  19. <script>
  20. /**
  21. * 键盘组件
  22. * @description 键盘组件
  23. * @property {String} mode 键盘模式
  24. * @property {Number} index 激活项index
  25. * @event {Function} change 键盘项变化事件
  26. * @event {Function} close 键盘关闭事件
  27. */
  28. export default {
  29. name: 'fs-keyboard'
  30. }
  31. </script>
  32. <script setup>
  33. import keyboardCar from './car.vue'
  34. import keyboardNum from './number.vue'
  35. const props = defineProps({
  36. modelValue: Boolean,
  37. mode: {
  38. type: String,
  39. default: 'car'
  40. },
  41. index: {
  42. type: Number,
  43. default: 0
  44. }
  45. })
  46. const emits = defineEmits(['update:modelValue', 'change', 'close'])
  47. const visible = computed({
  48. get: () => props.modelValue,
  49. set: value => emits('update:modelValue', value)
  50. })
  51. const handleChange = item => {
  52. emits('change', item)
  53. }
  54. const handleClose = () => {
  55. emits('update:modelValue', false)
  56. emits('close')
  57. }
  58. </script>
  59. <style lang="scss"></style>