Giter Site home page Giter Site logo

Comments (5)

aweiu avatar aweiu commented on August 22, 2024

没懂,把你的form-item或校验规则发来看看吧
然后这个"2eee"是指输入的内容么

from element-ui-verify.

zengcul avatar zengcul commented on August 22, 2024

不好意思 刚没把那段代码块引用下

<el-form-item label="库存总量" prop="left_amount" verify int >
      <el-input v-model.number="model.left_amount"></el-input>
 </el-form-item>

当输入数字开头后面跟上字母,数字验证失效,我的vue版本比您要求的高了点 不知道是不是这个原因,
image这么输入时不会提示错误,但是实际上model里绑定的值已经把字母过滤掉了 ,validate是成功的,仅仅是输入时不会提示错误

from element-ui-verify.

aweiu avatar aweiu commented on August 22, 2024

事实上,这个其实是v-model.number的特性

当你输入数字开头的字符时,v-model.number会取开头数字作为this.data.model.left_amount的值,也就是说实际上“2eee”只是个显示值,实际值是其实是数字2。如果你输入"2.1eee",同理插件会提示你”请输入整数“。更多细节可参考vue.toNumber源码

题外话,数字校验这里之前考虑过完全取输入值做强校验,这样可以使"显示值"与"实际值"保持一致,不过坏处是会对使用了v-model.number指令的人造成困惑

from element-ui-verify.

zengcul avatar zengcul commented on August 22, 2024

多谢作者耐心解释,加个type="number" 会不会好点 ,显示值输入的时候就会把非法字母给退回,毕竟那个现象是个bug

<el-form-item label="库存总量" prop="left_amount" verify int :gt="0">
      <el-input v-model.number="mainForm.left_amount" type="number"></el-input>
</el-form-item>

from element-ui-verify.

aweiu avatar aweiu commented on August 22, 2024

其实你可以考虑在输入框附近做一个label来实时显示输入的实际值

from element-ui-verify.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.