使用elementui 的时间选择器的时候 编辑回显的时候数据赋值的问题

使用elementui 的时间选择器的时候 编辑回显的时候数据赋值的问题

在使用elementui的时候, 我们把后台传过来的数据给放在之前所在的地方的时候,这个时候,我们的时间不会显示在组件里面

const start = res.data[0].runtime[i].substring(0, 5)
const stop = res.data[0].runtime[i].substring(6)
this.ruleForm.runtime[i].time[0] = start
this.ruleForm.runtime[i].time[1] = stop

这样我已经把我的数据和之前所展示的已经对应起来了,但是这个时候去看的话,在组件中是没有显示的,这个时候我们需要用到

this.$set(this.ruleForm.runtime[i], 'time', [start, stop])

直接设置进去

全部代码

for (let i = 0; i < res.data[0].runtime.length; i++) {
  	const start = res.data[0].runtime[i].substring(0, 5)
    const stop = res.data[0].runtime[i].substring(6)
    this.ruleForm.runtime[i].time[0] = start
    this.ruleForm.runtime[i].time[1] = stop
    this.$set(this.ruleForm.runtime[i], 'time', [start, stop])
}

版权声明:本文为jiangyue2694原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。