<input :placeholder="'最高可提现金额:'+totalRevenue+'元'" v-model="drawMoney" @keypress="isNumber($event)">
methods: {
    isNumber(evt) {
      evt = (evt) ? evt : window.event;
      let charCode = (evt.which) ? evt.which : evt.keyCode;
      if ((charCode > 31 && (charCode < 48 || charCode > 57)) && charCode !== 46) {
        evt.preventDefault();
      } else {
        let idx = this.drawMoney.indexOf('.');
        (idx > 0) && (idx + 2 < this.drawMoney.length) && evt.preventDefault();
        console.log(this.drawMoney)
      }
    }
}

石头
19 声望1 粉丝