Vue日期绑定未呈现

问题描述

我一直在搜索并尽我所能,让我的 type="date" 输入通过 v-model 绑定(和渲染)到数据对象。我在 Angular one 中很容易地做到了这一点,但 Vue 似乎并没有完全一样地处理它。

为了方便阅读,我把代码删减了

模板:

<input
      type="date"
      name="EndDay"
      id="EndDay"
      v-model="editedTime.endDay"
      required
/>

脚本:

  props: ['DBobj'],data() {
    return {
      editedTime: {
        startDay: "",endDay: "",},};
  },mounted(){
  //I've tried setting it to a new Date object (this worked in Angular 1):
  this.startDay = new Date(DBobj.startDay)

  //I've tried setting it to a moment object (practically the same,I kNow)
  this.startDay = moment(DBobj.startDay)

  //I've tried matching the input's date format
  this.startDay = moment(DBobj.startDay).format("MM/DD/YYYY")

  //I've tried simply setting it as the date.toString()
  this.startDay = new Date(DBobj.startDay).toString()
}

在Vue devtool中可以看到数据设置正确,但是输入框根本没有加载数据。

任何帮助将不胜感激!谢谢

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)