应用场景:
当一个日期改变的时候,另一个日期自动加13周显示
代码实现:
<template>
<div>
<el-date-picker
v-model="form.forecastDate"
@change="forecastDateChange"
:picker-options="pickerOptions"
type="date"
placeholder="选择日期"
style="width: 300px">
</el-date-picker>
<el-date-picker
disabled
v-model="form.applyTime"
type="date"
style="width: 300px">
</el-date-picker>
</div>
</template>
<script>
export default{
data(){
return{
form: {
forecastDate: '',
applyTime: '',
},
}
},
methods:{
forecastDateChange(val){
let newDate = new Date().setDate(val.getDate() + 12*7 + 6)
this.form.applyTime = new Date(newDate)//交付时间在需求时间13周后
this.form.returnDate = ''
},
},
}
</script>