In vue, the input box only allows numbers to be entered

 In the vue project, the input box only allows the input of numbers, and now I will record a method I use for reference!

 1. Inline insertion οninput="value=value.replace(/[^0-9.]/g,'')"

<el-input v-model.number="ruleForm.sort" placeholder="请输入数字(限数字)" oninput="value=value.replace(/[^0-9.]/g,'')" />

2. Use the InputNumber counter of element-ui

<el-input-number v-model="num" :min="1" :max="10" label="描述文字"></el-input-number>

If you don't need control buttons, just set controls to false

Guess you like

Origin blog.csdn.net/a15220216758/article/details/124469125