1. 只允许输入数字,并保留两位小数
html
<el-input
class="config-input"
type="number"
v-model="v.minHeight"
placeholder=""
:min="0"
@input="v.minHeight = Number(Number(v.minHeight).toFixed(2))"
/
- 只允许输入数字,不可以有小数
html
<el-input
class="self-area-input"
type="number"
v-model="selfMixtureArea.self1Times"
placeholder=""
:min="0"
@input="selfMixtureArea.self1Times = Number(selfMixtureArea.self1Times.toString().replace(/[^\d]/g, ''))"
/>
以上写法会影响负数输入,直接用el-input的精度参数:
html
<el-input v-model="storageArea.minHeight" type="number" :precision="2" :step="0.01"> </el-input>