芹菜是一根葱
专业解决各种前端Bug,吊打各种面试官

精度:小数点后十位

长度:30

<el-input
          v-if="node.pattern.rightSource == 'Custom'"
          v-model.number="node.pattern.rightValue"
          placeholder="请输入右值"
          style="width: 240px"
          maxlength="30"
          @input="handleInput"
          show-word-limit
        />
const handleInput = (value) => {
   // 正则表达式:禁止单独的小数点
    const regex = /^(\d+(\.\d{0,10})?|\.\d{1,10})$/;
    
    // 如果不符合格式,移除最后一个字符
    if (!regex.test(value)) {
      value = value.slice(0, -1);
    }
    
    // 更新绑定值
  props.node.pattern.rightValue = value
}

 不能以小数点开头。

posted on 2025-05-22 22:40  芹菜是一根葱  阅读(19)  评论(0)    收藏  举报