<el-input
v-model.number="formInline.locally_target_power"
onkeyup="if(isNaN(value))execCommand('undo')"
:readonly="readonly">
</el-input>
限制 input 输入框只能输入数字, 能输小数点.的正则表达式:
οnkeyup="if(isNaN(value))execCommand('undo')"
trim()判断空格
trim() 方法用于删除字符串的头尾空白符,空白符包括:空格、制表符 tab、换行符等其他空白符等。
const content = ' ' // 一列空格
console.log(content.trim() === '') // true
如果 content 是 number 数字类型, 需要转换成字符串类型, 否则会报错。
console.log(String(content).trim() === '') // true