Skip to content

Commit

Permalink
datetime: do not trigger on-change on first-value-setting
Browse files Browse the repository at this point in the history
  • Loading branch information
airyland committed Jun 1, 2017
1 parent 6614fab commit 529448e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/components/datetime/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export default {
displayFormat: Function
},
created () {
this.isFirstSetValue = false
this.currentValue = this.value
this.handleChangeEvent = true
},
Expand Down Expand Up @@ -177,9 +178,14 @@ export default {
}
},
watch: {
currentValue (val) {
this.$emit('on-change', val)
currentValue (val, oldVal) {
this.$emit('input', val)
if (!this.isFirstSetValue) {
this.isFirstSetValue = true
oldVal && this.$emit('on-change', val)
} else {
this.$emit('on-change', val)
}
this.validate()
},
startDate () {
Expand Down
5 changes: 5 additions & 0 deletions src/components/datetime/metas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ events:
en: $emits when value changes, `(newVal)`
zh-CN: 表单值变化时触发, 参数 `(newVal)`
changes:
next:
en:
- '[fix] do not trigger on-change on first-value-setting'
zh-CN:
- '[fix] 初始化时不触发 on-change 事件'
v2.2.1-rc.8:
en:
- '[enhance] now changing prop:format will trigger re-rendering'
Expand Down

0 comments on commit 529448e

Please sign in to comment.