<> one , Original code
<el-form-item class="form_bigt_p" label=" Project start and end time :" prop="time"> <el-date-picker
unlink-panels class="bigWidth" :disabled="isDisabled" v-model.trim="
ruleForm.time" type="daterange" value-format="timestamp" range-separator=" to "
start-placeholder=" Start date " end-placeholder=" End date " ></el-date-picker> </
el-form-item>
<> Because the data returned by the background is two yyyy-mm-dd Date of format (startTime,endTime), So we started with
this.ruleForm.time = [ this.baseDateTemp(res.data.startTime), this.baseDateTemp
(res.data.endTime), ]; //this.baseDateTemp It is a global method of converting date to time stamp
<> two , Problem finding and handling
<> problem
The date can be rendered in the el-date-picker upper , But it will not be echoed when it is modified
After testing, it was found that , This can be triggered input method , But it doesn't trigger change method
<> Treatment method
stay input It can be seen from the method , On modification ,el-date-picker Bound v-model The value of has changed , But there is no real-time update in the control
The final choice is to adopt this.$set Method to update the data , And successfully solve this problem
The revised code is as follows
<el-form-item class="form_bigt_p" label=" Project start and end time :" prop="time"> <el-date-picker
unlink-panels class="bigWidth" :disabled="isDisabled" v-model.trim="
ruleForm.time" type="daterange" value-format="timestamp" range-separator=" to "
start-placeholder=" Start date " end-placeholder=" End date " @input="testClick" ></
el-date-picker> </el-form-item> testClick(e) { this.$nextTick(() => { this.
ruleForm.time = null; this.$set(this.ruleForm, "time", [e[0], e[1]]); }); }, //
Convert the two dates obtained in the background to time The method is changed to this.$set(self.ruleForm, "time", [ this.baseDateTemp(res
.data.startTime), this.baseDateTemp(res.data.endTime) ]);
Technology