鍍金池/ 問(wèn)答/Android  HTML/ weex項(xiàng)目 input框內(nèi)不能輸入非數(shù)字類型的字符

weex項(xiàng)目 input框內(nèi)不能輸入非數(shù)字類型的字符

weex項(xiàng)目 input框內(nèi)不能輸入非數(shù)字類型的字符的功能不能實(shí)現(xiàn)

代碼如下:

<template>
 <input class="login-phone" type="number" placeholder="請(qǐng)輸入手機(jī)號(hào)碼" maxlength="11" :value="phone" @input="inputPhone" ref="aaaa">
</template>
<script>
created () {
    storage.getItem('phone', e => {
      if (e.result === 'success') {
        this.phone = e.data
      }
    })
  },
methods: {
    inputPhone (event) {
      // event.target= event.value.replace(/\D/g, '') // 不可行
      // this.phone = event.value.replace(/\D/g, '') // 不可行
      /** this.$refs.aaaa.setTextFormatter({
        formatRule: "/(\d)(\D)/g",
        formatReplace: "$1",
        recoverRule: "/\D/g",
        recoverReplace: ""
      }) */ // 沒(méi)有反應(yīng)
      this.phone = event.value
    }
}
</script>
回答
編輯回答
懷中人

沒(méi)有很好的辦法,只能通過(guò)js去控制

2018年3月3日 22:50