优设网网站设计评价,做网站的费用计入哪个科目,设计一套app页面多少钱,西安市规划建设局网站一、input
只能输入框只能输入正整数#xff0c;输入同时禁止了以0开始的数字输入#xff0c;防止被转化为其他进制的数值。
!-- 不能输入零时--
input typetext οninputvaluevalue.replace(/^(0)|[^\d]/g,)!-- 能输入零时--
inp…一、input
只能输入框只能输入正整数输入同时禁止了以0开始的数字输入防止被转化为其他进制的数值。
!-- 不能输入零时--
input typetext οninputvaluevalue.replace(/^(0)|[^\d]/g,)!-- 能输入零时--
input typetext οninputvaluevalue.replace(/^0(\d)|[^\d]/g,)
附只能输入中文:
input typetext οninputthis.valuethis.value.replace(/[^\u4e00-\u9fa5]/g,) 附只能输入英文:
input typetext οninputthis.valuethis.value.replace(/[^a-zA-Z]/g,) 二、el-input
el-input sizesmallοnkeyupvaluevalue.replace(/^(0)|[^\d]/g,)v-modelcountmaxlength9/el-input
data() {return {count: 0}
} el-input输入金额保留两位小数
需求“只允许输入金额保留两位小数”有2种实现方法
方法一通过正则控制
el-inputv-modelinputTable.amountinputformatNum(form.amount, amount)
/el-inputformatNum(val, key) {let temp val.toString();temp temp.replace(/。/g, .);temp temp.replace(/[^\d.]/g, ); //清除数字和.以外的字符temp temp.replace(/^\./g, ); //验证第一个字符是数字temp temp.replace(/\.{2,}/g, ); //只保留第一个, 清除多余的temp temp.replace(., $#$).replace(/\./g, ).replace($#$, .);temp temp.replace(/^(\-)*(\d)\.(\d\d).*$/, $1$2.$3); //只能输入两个小数this.form[key] temp;
},方法二使用组件
这个是我最近才发现的方便多了TT 设置精度precision即可四舍五入 再改改样式隐藏按钮靠左对齐最后效果和普通的input无异 el-input-number v-modelnum :precision2/el-input-number