ViewUIPlus
ViewUIPlus copied to clipboard
使用DatePicker就会报Uncaught (in promise) TypeError: Cannot read properties of null (reading 'slice')的错误
Hi @13543507643! I'm Dosu and I’m helping the ViewUIPlus team.
这个报错通常是因为传给 DatePicker 的 v-model 或 modelValue 是 null、undefined 或其他不兼容的值,导致内部的 .slice() 操作出错。DatePicker 期望 v-model/modelValue 始终是有效的日期字符串、空字符串,或者(多选/范围时)数组,不能为 null 或 undefined。
建议你检查一下传递给 DatePicker 的 v-model 或 modelValue,确保它的初始值不是 null,而是空字符串("")或合法的日期字符串。例如:
<template>
<DatePicker v-model="date" type="date" placeholder="Select date" style="width: 200px" />
</template>
<script setup>
import { ref } from 'vue'
const date = ref('')
</script>
如果你已经这样做但问题依然存在,可以提供一下 ViewUIPlus 的版本号,或者一个最小复现代码,方便进一步排查。
(技术细节参考:DatePicker 源码分析)
To reply, just mention @dosu.
How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other