当前位置:网站首页>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之间的数字,其他字符,均无法输入
边栏推荐
- jmeter生成测试报告
- sql注入绕过方法总结
- Redis - 7、事務操作
- CF751E Phys Ed Online
- Exchange the nodes in the linked list in pairs [the principle of one-way linked list without chain]
- Redis - 8. Persistent RDB (redis database)
- APM flight mode switching -- source code explanation
- 云上人和物联科技加入龙蜥社区,携手打造软硬件服务生态
- [2206] An Improved One millisecond Mobile Backbone
- Collection of IO operation cases
猜你喜欢

推荐系统从入门到接着入门

Take Wei Lai to court. What's Audi's hurry?

本地裸文件包含

Redis - 12. Application problem solving

“不敢去怀疑代码,又不得不怀疑代码”记一次网络请求超时分析

Redis - 11. Cluster

APM set pitch four rotor control mode

Redis - 3、发布和订阅

Redis - 7. Transaction operation

Share 7 free super clear video resource stations! Both editing and collection are practical enough to cry!
随机推荐
Call center CTI system
Redis - 11、集群(Cluster)
“不敢去怀疑代码,又不得不怀疑代码”记一次网络请求超时分析
[high frequency written test questions] 513 Find the value in the lower left corner of the tree
Redis - 7、事务操作
CF751 C. Optimal Insertion
Redis - 9. Persistent AOF (append onlyfile)
[cloud native | kubernetes] Introduction to kubernetes (I)
Linux Installation and deployment mysql5.7 (enterprise common Edition) ultra detailed
“中国巴菲特”段永平:投资有道
Summary of SQL injection bypass methods
MAUI使用Masa blazor组件库
论文解读——Temporal Recommendation on Graphs via Long- and Short-term Preference Fusion
Fight, programmer - Chapter 37 The Xiongguan pass is like an iron road. Now, I'm going to cross it from the beginning
1.11 haas506 2.0开发教程-driver-RTC(仅支持2.2以上版本)
Messari年度报告-2021
OceanBase数据库助力理想汽车智能生产线 可实现30秒内自动恢复
Linux安装部署MySQL5.7(企业常用版)超详细
传统零售加速向新零售演进升级,零售数字化势在必行
JMeter generates test reports