<el-date-picker
ref="picker"
v-model="form2.time"
value-format="yyyy-MM-dd"
class="w200"
:type="pickerType"
placeholder="选择日期"
:picker-options="pickerOptions"
:key="pickerType"
@change="handleClick"
/>
data() {
return {
form2:{},
pickerType: 'date',
pickerOptions: {
shortcuts: [{
text: '今天',
onClick: (picker) => {
this.changeType('date')//自行修改
}
}, {
text: '月份',
onClick: (picker) => {
this.changeType('month')//自行修改
}
}]
}
}
},
methods:{
changeType(type) {
this.pickerType = type
this.$nextTick(() => {
this.$refs.picker.focus()
if (type === 'date') {
this.form2.time = new Date()
}
})
}
element 时间(el-date-picker)动态修改type
最新推荐文章于 2024-06-20 09:23:17 发布