Closed lidong6392 closed 3 years ago
hao
后续版本应该会修复这个问题,如果项目中不能随便升版本的话,下面的方法可以暂时解决这个问题
<el-date-picker v-model="date" @blur="datePickerBlur" />
datePickerBlur(vm) () { if (!this.date && vm&& vm.picker) { vm.picker.rangeState.startDate = ''; vm.picker.rangeState.endDate = ''; vm.picker.rangeState.selecting = false; } }
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Element UI version
2.12.0
OS/Browsers version
mac OS / Google Chrome
Vue version
2.6.10
Reproduction Link
https://codepen.io/kaola-fed/pen/LYYBYdP?&editable=true
Steps to reproduce
What is Expected?
再次打开控件,选中第一个时间时不要直接进入赋值逻辑,而是暂存为开始时间,点击第二个时间才进入赋值逻辑。这样才符合用户的期望:先选一个开始时间,再选一个结束时间,操作结束。
What is actually happening?
组件虽然进行了一些界面上的重置工作,但是rangeState.selecting仍是true,此次操作直接会进入赋值逻辑: ”if (this.selectionMode === 'range') { if (!this.rangeState.selecting) { this.$emit('pick', {minDate: newDate, maxDate: null}); this.rangeState.selecting = true; } else { if (newDate >= this.minDate) { this.$emit('pick', {minDate: this.minDate, maxDate: newDate}); } else { this.$emit('pick', {minDate: newDate, maxDate: this.minDate}); } this.rangeState.selecting = false; } } “ 并且因为没有开始时间会进入newDate >= this.minDate的赋值逻辑,把值直接赋给了结束时间。