vue element input 控制限制只能输入13位整数和4位小数

  • Post author:
  • Post category:vue


input

<el-form-item label="员工在岗月考核" prop="userFactor" > 
		<el-input v-model="popform.userFactor" :disabled="inShow" clearable :style="setWidStyle" type="number"></el-input> 
</el-form-item>

监听

	watch: {
		'popform.userFactor': function (newval, oldval) {
			   var reg = /^(\d{0,13})(\.(\d{0,4}))?$/g;
				if (!reg.test(newval)) {
					if (newval == undefined || newval == null ) {
						this.popform.userFactor = '';
						return;
					}
					this.popform.userFactor = oldval
				} else {
					this.popform.userFactor = newval.replace(/^\./g, "")
				}
				console.log('popform.userFactor',this.popform.userFactor)
			}
	},

在这里插入图片描述



版权声明:本文为weixin_38069018原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。