Skip to content

Commit 8fffaa6

Browse files
feat: ✨ 为Picker和SelectPicker补充clear事件
1 parent 7584ac2 commit 8fffaa6

File tree

4 files changed

+7
-3
lines changed

4 files changed

+7
-3
lines changed

docs/component/picker.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,10 @@ function handleConfirm({ value }) {
288288

289289
| 事件名称 | 说明 | 参数 | 最低版本 |
290290
| -------- | ---------------------- | ----------------------------------------------------------------------------------------------------------- | -------- |
291-
| confirm | 点击右侧按钮触发 | event.detail = { value, selectedItems }, value 为选中值(多列则为数组),selectedItems为选中项(多列则为数组) | - |
291+
| confirm | 点击右侧按钮触发 | { value, selectedItems }, value 为选中值(多列则为数组),selectedItems为选中项(多列则为数组) | - |
292292
| cancel | 点击左侧按钮触发 | - | - |
293293
| open | 打开选择器弹出层时触发 | - | - |
294+
| clear | 点击清空按钮时触发 | - | $LOWEST_VERSION$ |
294295

295296
## Methods
296297

docs/component/select-picker.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,7 @@ function handleConfirm({ value, selectedItems }) {
388388
| cancel | 点击关闭按钮或者蒙层时触发 | - | - |
389389
| close | 弹窗关闭时触发 | - | 1.2.29 |
390390
| open | 弹窗打开时触发 | - | 1.2.29 |
391+
| clear | 点击清空按钮时触发 | - | $LOWEST_VERSION$ |
391392

392393
## Methods
393394

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ import { pickerProps, type PickerExpose } from './types'
9595
const { translate } = useTranslate('picker')
9696
9797
const props = defineProps(pickerProps)
98-
const emit = defineEmits(['confirm', 'open', 'cancel', 'update:modelValue'])
98+
const emit = defineEmits(['confirm', 'open', 'cancel', 'clear', 'update:modelValue'])
9999
100100
const pickerViewWd = ref<PickerViewInstance | null>(null)
101101
const cell = useCell()
@@ -393,6 +393,7 @@ const showClear = computed(() => {
393393
function handleClear() {
394394
const clearValue = isArray(pickerValue.value) ? [] : ''
395395
emit('update:modelValue', clearValue)
396+
emit('clear')
396397
}
397398
398399
// 是否展示箭头

src/uni_modules/wot-design-uni/components/wd-select-picker/wd-select-picker.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ import { selectPickerProps, type SelectPickerExpose } from './types'
135135
const { translate } = useTranslate('select-picker')
136136
137137
const props = defineProps(selectPickerProps)
138-
const emit = defineEmits(['change', 'cancel', 'confirm', 'update:modelValue', 'open', 'close'])
138+
const emit = defineEmits(['change', 'cancel', 'confirm', 'clear', 'update:modelValue', 'open', 'close'])
139139
140140
const pickerShow = ref<boolean>(false)
141141
const selectList = ref<Array<number | boolean | string> | number | boolean | string>([])
@@ -438,6 +438,7 @@ const showClear = computed(() => {
438438
439439
function handleClear() {
440440
emit('update:modelValue', props.type === 'checkbox' ? [] : '')
441+
emit('clear')
441442
}
442443
443444
// 是否展示箭头

0 commit comments

Comments
 (0)