前言: 对页面数据进行编辑时,需要对各类信息进行回显,包括时间
html:
<el-date-picker
v-model="ruleForm.time"
type="datetimerange"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期">
</el-date-picker>
赋值(赋值后不能修改)
this.ruleForm.time = [new Date(), new Date()]
$set 赋值(可修改)
this.$set(this.ruleForm, "time", [new Date(), new Date()])
set用法
this.$set(原数组, 索引值, 需要赋的值)
我这个获取的时间是数组格式,Vue 不能检测数组的变动,当数据没有被双向绑定的时候,就需要使用$set了
只要值的地址没有改变,vue是检测不到数据变化的