当前位置:网站首页>input输入框只能输入,0-100之间的数组,保留两位小数
input输入框只能输入,0-100之间的数组,保留两位小数
2022-06-22 11:45:00 【逆风优雅】
通过计算属性,处理一下输入的值(具体写法可以看下面代码的注释)
computed: {
techInputData: { // 科技人员input输入框输入的值
get() {
var value = this.tableData.scienceStaffNumPer // 将输入框的值赋值给value
if (Number(value)!==parseFloat(value)) { // 判断输入的是否是数字,如果不是,返回空
return ''
}
if (value < 0) { // 如果输入的值小于0
return 0;
} else if (value >= 100) { // 如果输入的值大于等于100
return 100;
} else {
return value.toString().match(/^\d+(?:\.\d{0,2})?/) // 只能输入小数点后两位
}
},
set(val) {
this.tableData.scienceStaffNumPer = val; // 重新将计算属性处理过的值,赋值给这个input
},
},
}此代码只能,输入0-100之间的数字,其他字符,均无法输入
边栏推荐
- [安洵杯 2019]iamthinking
- Solution to 55e of Niuke challenge
- What is homology??? Cross domain error??? How to solve???
- Haas506 2.0 development tutorial - Advanced Component Library -modem Info (only supports versions above 2.2)
- Redis - 4、新的3种数据类型
- Explanation of 94F question in Niuke practice match
- Bytestream case of IO
- Redis - 3. Publish and subscribe
- 机器学习与深度学习 --- 激活函数(未完待续)
- Redis - 10. Master slave replication
猜你喜欢

Redis - 7、事务操作

Redis - 11、集群(Cluster)

Foreign lead needs energy, interest, research, diligence and is indispensable

国外LEAD需要干劲、兴趣、钻研、勤奋、缺一不可

【李宏毅】机器学习深度学习笔记 -- 训练模型通关攻略

More than half of 2022, no new air outlet

Linux安装部署MySQL5.7(企业常用版)超详细

Redis - 3、发布和订阅

Redis - 4. Three new data types

Redis - 12. Application problem solving
随机推荐
《Go题库·10》channel和锁的对比
[cloud native | kubernetes] Introduction to kubernetes (I)
Configure the GPU version of pytorch and torchvision, and learn the GPU version of torch step
Niuke challenge 53c
In C # development, the third-party components lambdaparser, dynamicexpresso and z.expressions are used to dynamically parse / evaluate string expressions
Niuke challenge 54F problem solution & Li Chaoshu's learning notes
俞敏洪称未来可能开电商学院;马斯克儿子申请断绝父子关系;饿了么回应大量用户收到免单信息;B站上线付费视频...
Messari年度报告-2021
论文解读——Factorization Meets the Neighborhood: a Multifaceted Collaborative Filtering Model
Traditional retail is accelerating the evolution and upgrading to new retail, and retail digitalization is imperative
马尔可夫链(Markov Chain),隐马尔可夫模型
Redis - 3、发布和订阅
Authenticated cookies, sessions, JWT
[ciscn2019 finals Day1 web4]laravel1
Solution to 94d problem of Niuke practice match
Foreign lead needs energy, interest, research, diligence and is indispensable
chown改变目录的所有者、所属组失败的诡异问题
Local raw file contains
Noi use cases
CAT敏捷团队教练工作坊 (Coaching Agile Teams) | 8月20日开课