fix(stepper & input-item): avoid triggering change events when initia… (#512)

* fix(stepper & input-item): avoid triggering change events when initializing assignments

#495

* doc(stepper): remove default-value
This commit is contained in:
Shawn Xu 2019-07-29 10:42:02 +08:00 committed by GitHub
parent cafa5bbe18
commit b427bcfeed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 6 deletions

View File

@ -298,8 +298,10 @@ export default {
inputValue(val) {
this.inputBindValue = val
val = this.isFormative ? this.$_trimValue(val) : val
this.$emit('input', val)
this.$emit('change', this.name, val)
if (val !== this.value) {
this.$emit('input', val)
this.$emit('change', this.name, val)
}
},
isInputFocus(val) {
if (!this.isVirtualKeyboard || !this.inputNumberKeyboard) {

View File

@ -22,7 +22,6 @@ Vue.component(Stepper.name, Stepper)
|Props | Description | Type | Default |
|---------|------|--------|----|
|v-model | current value | Number/String |-|
|default-value |stepper initial value| Number/String|-|
|step|the number of steps can be changed and be a decimal|Number/String|`1`|
|min|minimum|Number/String|`-Infinity`|
|max|maximum|Number/String|`Infinity`|

View File

@ -22,7 +22,6 @@ Vue.component(Stepper.name, Stepper)
|属性 | 说明 | 类型 | 默认值|
|---------|------|--------|----|
|v-model| 当前值 | Number/String |-|
|default-value |默认值| Number/String|-|
|step|每次改变步数,可以为小数|Number/String|`1`|
|min|最小值|Number/String|`-Infinity`|
|max|最大值|Number/String|`Infinity`|

View File

@ -130,8 +130,10 @@ export default {
currentNum(val, oldVal) {
this.$_checkStatus()
this.$emit('input', val)
this.$emit('change', val)
if (val !== this.value) {
this.$emit('input', val)
this.$emit('change', val)
}
const diff = val - oldVal