选择前一年:
<el-form-item label="年份:" prop="pro_years"><el-date-pickerv-model="getFormData.pro_years"type="year"style="width: 100%":disabled="getNotUse"format="yyyy"value-format="yyyy" :picker-options="pickerOptions"placeholder="请选择年份"></el-date-picker>
</el-form-item>
return {
pickerOptions: {disabledDate: (time) => {let minYear = new Date().getFullYear() - 1return time > Date.now() || time.getTime() < new Date(JSON.stringify(minYear))} },
}
效果:
选择后一年:
<el-form-item label="年份:" prop="pro_years"><el-date-pickerv-model="getFormData.pro_years"type="year"style="width: 100%":disabled="getNotUse"format="yyyy"value-format="yyyy" :picker-options="pickerOptions"placeholder="请选择年份"></el-date-picker>
</el-form-item>
return {
return {pickerOptions:{disabledDate: (time) => {let nowYear = new Date().getFullYear();return time.getFullYear()>nowYear+1;}},
}
效果: