Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.9k views
in Technique[技术] by (71.8m points)

element ui的el-date-picker日期组件,默认值不能为空吗?

我用的element ui的el-date-picker日期组件,
允许了可以为空,也符合了我写的校验规则。
但是后端报错。说的空字符串无法转化为日期对象。
我该怎么做呢?
是不是日期不能默认为空字符串呢?那默认写什么日期呢?0000-00-00吗?
image.png
image.png


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

以你的描述,为空时是不能给后端传空字符串的,否则会报错;你可以传null/undefined试试或者不传该字段,当然还是报错,得询问后端接收的字段是什么格式


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...