<dy-input v-model="price" @input="inputChange" @blur="handleBlur"/>
Js check can only enter the amount with two decimal digits:
Data (){return {info:{source:" account ", price:"", other:""}}, InputChange (){// limit input to 8 bits this.price = this.price. Replace (/\d{8}/, ") // If input is not a number, Is replaced by ' 'this. Price = this. Price. Replace (/ ^ \ \. D/g, "); This.price = this.price. Replace (/^\./g, ""); // Ensure that only one occurs. But no more. This. Price = this. Price. Replace (/ \. {2} / g, '. '); / / the first two is not 0 digital enclosing price = this. Price. Replace (/ ^ 0 \ [0-9] * d/g, "); / / that. Only once, and can't appear more than twice this. Price = this. Price. Replace ('. ', '$# $'). The replace (/ \. J/g, "). The replace (' $# $','. '); / / input only two decimal places this. Price = this. Price. Replace (/ ^ (\ -) * (\ d +) \. (\ d \ d). * $/, '$1 $2. $3'); {}, handleBlur () if (this. Price = = "") {this. Price =" 0.00 "}},Copy the code