@@ -76,15 +76,19 @@ export default {
7676 },
7777
7878 watch: {
79+ placeholder : function () {
80+ this .quantity = ! this .placeholder ? this .min : null
81+ },
7982 quantity : function () {
8083 this .evaluateQuantity ()
8184 },
8285 min : function (val ) {
83- if (this .quantity < val) this .quantity = val
86+ if (this .quantity < val) {
87+ this .quantity = val
88+ }
8489 },
8590 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
8892 }
8993 },
9094
@@ -99,23 +103,39 @@ export default {
99103
100104 emitChange (init = false ) {
101105 this .oldValue = this .quantity
102- if (init) this .quantity = this .min
106+
107+ if (init && ! this .placeholder ) {
108+ this .quantity = this .min
109+ }
110+
103111 this .$emit (' onInputNumberChange' , this .quantity , init)
104112 },
105113
106114 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+ }
110122 },
111123
112124 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+ }
116132 },
117133
118134 onBlur () {
135+ if (this .placeholder && ! this .quantity ) {
136+ return
137+ }
138+
119139 if (this .quantity .toString ().length === 0 ) {
120140 this .quantity = this .oldValue
121141 return
@@ -141,6 +161,7 @@ export default {
141161 if (this .isKeydown ) return
142162
143163 if (
164+ ! this .placeholder &&
144165 this .quantity .toString ().length > 0 &&
145166 this .quantity !== this .oldValue
146167 ) {
0 commit comments