在 Vue 中,如何将日期对象绑定到日期输入?(v 模型不起作用) [英] In Vue, how do I bind a date object to a date input ? (v-model doesn't work)
本文介绍了在 Vue 中,如何将日期对象绑定到日期输入?(v 模型不起作用)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
// This doesn't work
<input type='date' v-model='store.myDateObject'>
如何将日期输入绑定到我商店中的日期对象?
How can I bind a date input to a date object in my store?
推荐答案
假设您希望您的日期作为午夜 UTC 日期对象,请执行此操作...
Assuming you want your dates as midnight UTC date objects, do this...
<input type='date'
:value='store.myDate.toJSON().substring(0,10)'
@input='store.myDate = new Date($event.target.value)'
>
这篇关于在 Vue 中,如何将日期对象绑定到日期输入?(v 模型不起作用)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文