<template>
  <el-input v-model="item.inputValue" type="text" placeholder="" @input="handleInput"></el-input>
</template>
<script>
export default {
  data() {
    return {
      item: {
        inputValue: ''
      }
    };
  },
  methods: {
    handleInput(event) {
      // 使用正则表达式过滤输入的内容,只保留数字
      event.target.value = event.target.value.replace(/[\^\d]/g, '');
    }
  }
};
</script>

原文地址: https://www.cveoy.top/t/topic/pNdy 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录