Skip to content

Commit 875e072

Browse files
fix: 🐛 修复NumberKeyboard组件使用 title 插槽未传入关闭文本时不展示头部的问题 (#1060)
Closes: #760
1 parent f1ad2fa commit 875e072

4 files changed

Lines changed: 26 additions & 9 deletions

File tree

docs/component/number-keyboard.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
虚拟数字键盘,用于输入数字、密码或身份证等场景。
44

5+
:::danger 注意⚠️
6+
虚拟数字键盘功能已移动至[KeyBoard](./keyboard)组件中,请及时迁移,本组件于`1.10`版本废弃。
7+
:::
8+
59
## 基本用法
610

711
可以通过 `v-model:visible` 控制键盘是否展示。

docs/en-US/component/number-keyboard.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
Virtual numeric keyboard, used for inputting numbers, passwords, or ID cards and other scenarios.
44

5+
:::danger Warning⚠️
6+
The virtual numeric keyboard functionality has been moved to the [KeyBoard](./keyboard) component. Please migrate as soon as possible. This component will be deprecated in version `1.10`.
7+
:::
8+
59
## Basic Usage
610

711
You can control whether the keyboard is displayed through `v-model:visible`.

src/uni_modules/wot-design-uni/components/wd-keyboard/wd-keyboard.vue

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
@click-modal="handleClose"
1111
>
1212
<view :class="`wd-keyboard ${customClass}`" :style="customStyle">
13-
<view class="wd-keyboard__header" v-if="showTitle || $slots.title">
14-
<slot name="title">
13+
<view class="wd-keyboard__header" v-if="showHeader">
14+
<slot name="title" v-if="showTitle">
1515
<text class="wd-keyboard__title">{{ title }}</text>
1616
</slot>
1717
<view class="wd-keyboard__close" hover-class="wd-keyboard__close--hover" v-if="showClose" @click="handleClose">
@@ -51,7 +51,7 @@ export default {
5151
</script>
5252

5353
<script lang="ts" setup>
54-
import { computed, ref, watch } from 'vue'
54+
import { computed, ref, watch, useSlots } from 'vue'
5555
import wdPopup from '../wd-popup/wd-popup.vue'
5656
import WdKey from './key/index.vue'
5757
import { keyboardProps, type Key } from './types'
@@ -60,6 +60,7 @@ import { CAR_KEYBOARD_AREAS, CAR_KEYBOARD_KEYS } from './constants'
6060
6161
const props = defineProps(keyboardProps)
6262
const emit = defineEmits(['update:visible', 'input', 'close', 'delete', 'update:modelValue'])
63+
const slots = useSlots()
6364
6465
const show = ref(props.visible)
6566
watch(
@@ -77,7 +78,11 @@ const showClose = computed(() => {
7778
})
7879
7980
const showTitle = computed(() => {
80-
return props.title || showClose.value
81+
return !!props.title || !!slots.title
82+
})
83+
84+
const showHeader = computed(() => {
85+
return showTitle.value || showClose.value
8186
})
8287
8388
/**

src/uni_modules/wot-design-uni/components/wd-number-keyboard/wd-number-keyboard.vue

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
@click-modal="handleClose"
1111
>
1212
<view :class="`wd-number-keyboard ${customClass}`" :style="customStyle">
13-
<view class="wd-number-keyboard__header" v-if="showTitle">
14-
<slot name="title">
13+
<view class="wd-number-keyboard__header" v-if="showHeader">
14+
<slot name="title" v-if="showTitle">
1515
<text class="wd-number-keyboard__title">{{ title }}</text>
1616
</slot>
1717
<view class="wd-number-keyboard__close" hover-class="wd-number-keyboard__close--hover" v-if="showClose" @click="handleClose">
@@ -43,14 +43,14 @@ export default {
4343

4444
<script lang="ts" setup>
4545
import wdPopup from '../wd-popup/wd-popup.vue'
46-
import { computed, ref, watch } from 'vue'
46+
import { computed, ref, useSlots, watch } from 'vue'
4747
import WdKey from './key/index.vue'
4848
import { numberKeyboardProps, type Key } from './types'
4949
import type { NumberKeyType } from './key/types'
5050
5151
const props = defineProps(numberKeyboardProps)
5252
const emit = defineEmits(['update:visible', 'input', 'close', 'delete', 'update:modelValue'])
53-
53+
const slots = useSlots()
5454
const show = ref(props.visible)
5555
watch(
5656
() => props.visible,
@@ -66,7 +66,11 @@ const showClose = computed(() => {
6666
})
6767
6868
const showTitle = computed(() => {
69-
return props.title || showClose.value
69+
return !!props.title || !!slots.title
70+
})
71+
72+
const showHeader = computed(() => {
73+
return showTitle.value || showClose.value
7074
})
7175
7276
/**

0 commit comments

Comments
 (0)