diff --git a/src/components/random-money/index.vue b/src/components/random-money/index.vue index 94f6829..f565494 100644 --- a/src/components/random-money/index.vue +++ b/src/components/random-money/index.vue @@ -85,8 +85,7 @@ export default { this.inputNickname = res.nickname; }, onMoneyInput(e){ - console.log(e.target.value) - this.number = this.money + this.number = e.target.value }, changeMoney(){ const rand = Math.floor(Math.random() * this.randList.length); diff --git a/src/mixins/index.js b/src/mixins/index.js index 5078a31..0d9d848 100644 --- a/src/mixins/index.js +++ b/src/mixins/index.js @@ -7,7 +7,8 @@ export default { numberOnly: { bind: function(el) { el.handler = function() { - el.value = el.value.replace(/\D+/, '') + // el.value = el.value.replace(/\D+/, '') + el.value = el.value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1') } el.addEventListener('input', el.handler) },