Element-ui date and time control problem

  • it is OK to assign an initial value to the control, but there is no way to change the value through the control without reporting an error. It is very strange. I have been working on it for two days.
<el-date-picker
    v-model="dataForm.time = new Date("2018-08-08")"
    type="datetime"
    placeholder="">
</el-date-picker>
  • as shown in the figure: initialization assignment is possible:

clipboard.png

  • ::

clipboard.png

  • date cannot be selected, and the control will not disappear after clicking OK. Under normal circumstances, you should be able to select a date and time, and then click OK and the date and time should appear in the input box
.

Yes, silly boy.

your v-model binds an expression and executes dataForm.time = new Date ('2018-08-08') every time it is updated.

generally speaking, initial values are assigned directly to data

data(){
    return {
        dataForm:{
            time:new Date(),
        }
    }
}
Menu