1.采用计算属性set和get钩子
<el-date-picker
v-model="contractPeriod"
:clearable="false"
end-placeholder="结束日期"
placeholder="请选择"
size="small"
start-placeholder="开始日期"
style="width: 100%"
type="daterange"
value-format="yyyy-MM-dd"
@change="changeContractPeriod"
/>
2.计算属性
contractPeriod: {
get: function () {
return [this.dzdForm.contractPeriod, this.dzdForm.contractPeriodEnd];
},
set: function (val) {
this.dzdForm.contractPeriod = val[0];
this.dzdForm.contractPeriodEnd = val[1];
},
},
3.选择器change事件
changeContractPeriod(value) {
const [contractPeriod, contractPeriodEnd] = value;
this.dzdForm.contractPeriod = contractPeriod;
this.dzdForm.contractPeriodEnd = contractPeriodEnd;
console.log("合同期限", this.dzdForm.contractPeriod);
},