-----输入框------
<el-form-item label="工作时长(小时):" prop="worktimelong" >
<el-input v-model="handleform.worktimelong" placeholder="请输入工作时长" />
</el-form-item>
-----监听------
watch: {
'handleform.worktimelong': function (newval, oldval) {
var reg = /^(\d{0,6})(\.(\d{0,2}))?$/g;
if (!reg.test(newval)) {
if (newval == undefined) {
this.handleform.worktimelong = undefined;
return;
}
this.handleform.worktimelong = oldval
} else {
this.handleform.worktimelong = newval.replace(/^\./g, "")
}
}
}
来源:CSDN
作者:待接收那附件
链接:https://blog.csdn.net/xuewuzhijing98/article/details/104551801