Comments (5)
没懂,把你的form-item
或校验规则发来看看吧
然后这个"2eee"是指输入的内容么
from element-ui-verify.
不好意思 刚没把那段代码块引用下
<el-form-item label="库存总量" prop="left_amount" verify int >
<el-input v-model.number="model.left_amount"></el-input>
</el-form-item>
当输入数字开头后面跟上字母,数字验证失效,我的vue版本比您要求的高了点 不知道是不是这个原因,
这么输入时不会提示错误,但是实际上model里绑定的值已经把字母过滤掉了 ,validate是成功的,仅仅是输入时不会提示错误
from element-ui-verify.
事实上,这个其实是v-model.number的特性
当你输入数字开头的字符时,v-model.number
会取开头数字作为this.data.model.left_amount
的值,也就是说实际上“2eee”只是个显示值,实际值是其实是数字2。如果你输入"2.1eee",同理插件会提示你”请输入整数“。更多细节可参考vue.toNumber
源码
题外话,数字校验这里之前考虑过完全取输入值做强校验,这样可以使"显示值"与"实际值"保持一致,不过坏处是会对使用了v-model.number
指令的人造成困惑
from element-ui-verify.
多谢作者耐心解释,加个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.
其实你可以考虑在输入框附近做一个label来实时显示输入的实际值
from element-ui-verify.
Related Issues (20)
- el-select 和 el-input 校验形式不同 HOT 10
- 能否提供一份编译完的js HOT 2
- 引入后报错 ELEMENT is not defined HOT 2
- 应该增加maxLength的功能 用的也比较多 HOT 2
- 如何校验 日期,数组等数据类型? HOT 1
- alias 未生效 HOT 1
- 与element2.9.1版本冲突了么 HOT 2
- 默认校验规则 number异常 HOT 2
- 请问触发完所有校验时,如何focus第一个input控件 HOT 5
- 请问如何使用maxDecimalLength: 校验数字最大小数位 HOT 4
- 你好,请问这个校验不能兼容2.8.2以上的element ui的版本 HOT 1
- v1.2.0 typings 报错 HOT 3
- 关于multiple 自动触发非空校验 HOT 2
- 请问此插件现在支持ie吗,如果需要支持ie9以上需要做哪些? HOT 2
- 【BUG】ts编译后引用出错 exports is not defined HOT 2
- 可以改变默认的element-ui校验错误提示样式吗?使用冒泡方式提示错误 HOT 1
- alias设计不错,人性化,傻瓜化。。。 HOT 1
- 关于动态表单校验问题 HOT 1
- Element-UI 的表单校验,看来好多人都挺讨厌的
- 什么时候出vue3版本 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from element-ui-verify.