The default-value attribute ElementUI el-datepicker component does not work

default-value property has no reason for the reason that the v-model binding value.
Because the value of v-model bound to set the default time, when the selection box is opened it will give priority to whichever value v-model binding.

How do both bind v-model and use the default-value it?

The answer is to set the value of v-model binding is null or undefined or an empty string, you can not resolve the value of v-model binding when such a selection box opens, followed by the retreat takes the value default-value property.

I like this code below

<template>
	<el-date-picker size="small"
				type="date"
				placeholder="选择日期"
				:picker-options="pickerOptions"
				format="yyyy - MM - dd"
				value-format="timestamp"
				v-model="birth"
				:default-value="new Date()"
				:editable="false">
	</el-date-picker>
</template>

<script>
	export default {
		name: 'Profile',
		data() {
			return {
				//也可以为birth赋值为null或undefined
				birth: ''
			}
		}
	}
</script>
Released four original articles · won praise 0 · Views 167

Guess you like

Origin blog.csdn.net/qq_40378165/article/details/104417642