fix: 🐛 修复PickerView在绑定值为0时无法生效的问题

This commit is contained in:
xuqingkai 2024-04-12 10:05:36 +08:00
parent 2d94dd417c
commit 742b4d6525

View File

@ -43,7 +43,7 @@ export default {
</script> </script>
<script lang="ts" setup> <script lang="ts" setup>
import { getCurrentInstance, ref, watch, nextTick } from 'vue' import { getCurrentInstance, ref, watch, nextTick } from 'vue'
import { deepClone, getType, isArray, isEqual, isFunction, range } from '../common/util' import { deepClone, getType, isArray, isDef, isEqual, isFunction, range } from '../common/util'
import { formatArray, pickerViewProps, type PickerViewExpose } from './types' import { formatArray, pickerViewProps, type PickerViewExpose } from './types'
const props = defineProps(pickerViewProps) const props = defineProps(pickerViewProps)
@ -58,7 +58,7 @@ const preSelectedIndex = ref<Array<number>>([])
watch( watch(
() => props.modelValue, () => props.modelValue,
(newValue, oldValue) => { (newValue, oldValue) => {
if (!isEqual(oldValue, newValue) && newValue) { if (!isEqual(oldValue, newValue) && isDef(newValue)) {
selectWithValue(newValue) selectWithValue(newValue)
} }
}, },