el-input只能输入数字

588 阅读1分钟

方法1:

<el-input oninput="value=value.replace(/[^\d.]/g,'')" />

方法2:

<el-input type="number" />
<style scoped>
::v-deep input::-webkit-outer-spin-button,
::v-deep input::-webkit-inner-spin-button {
  -webkit-appearance: none !important;
}
::v-deep input[type='number'] {
  -moz-appearance: textfield !important;
  }
</style>