@@ -76,15 +76,19 @@ export default {
76
76
},
77
77
78
78
watch: {
79
+ placeholder : function () {
80
+ this .quantity = ! this .placeholder ? this .min : null
81
+ },
79
82
quantity : function () {
80
83
this .evaluateQuantity ()
81
84
},
82
85
min : function (val ) {
83
- if (this .quantity < val) this .quantity = val
86
+ if (this .quantity < val) {
87
+ this .quantity = val
88
+ }
84
89
},
85
90
max : function (val ) {
86
- if (this .quantity > val) this .quantity = val
87
- else this .quantity = this .min
91
+ this .quantity = this .quantity > val ? val : this .min
88
92
}
89
93
},
90
94
@@ -99,23 +103,39 @@ export default {
99
103
100
104
emitChange (init = false ) {
101
105
this .oldValue = this .quantity
102
- if (init) this .quantity = this .min
106
+
107
+ if (init && ! this .placeholder ) {
108
+ this .quantity = this .min
109
+ }
110
+
103
111
this .$emit (' onInputNumberChange' , this .quantity , init)
104
112
},
105
113
106
114
increment () {
107
- this .quantity = this .quantity < this .max
108
- ? this .quantity + this .step
109
- : this .max
115
+ if (! this .quantity ) {
116
+ this .quantity = this .min
117
+ } else {
118
+ this .quantity = this .quantity < this .max
119
+ ? this .quantity + this .step
120
+ : this .max
121
+ }
110
122
},
111
123
112
124
decrement () {
113
- this .quantity = this .quantity > this .min
114
- ? this .quantity - this .step
115
- : this .min
125
+ if (! this .quantity ) {
126
+ this .quantity = this .min
127
+ } else {
128
+ this .quantity = this .quantity > this .min
129
+ ? this .quantity - this .step
130
+ : this .min
131
+ }
116
132
},
117
133
118
134
onBlur () {
135
+ if (this .placeholder && ! this .quantity ) {
136
+ return
137
+ }
138
+
119
139
if (this .quantity .toString ().length === 0 ) {
120
140
this .quantity = this .oldValue
121
141
return
@@ -141,6 +161,7 @@ export default {
141
161
if (this .isKeydown ) return
142
162
143
163
if (
164
+ ! this .placeholder &&
144
165
this .quantity .toString ().length > 0 &&
145
166
this .quantity !== this .oldValue
146
167
) {
0 commit comments