封装el-input组件,限制输入为数值类型(vue)
- 封装组件
<template>
<el-input
v-bind="$attrs"
v-on="$listeners"
v-model="inputVal"
:maxlength="maxlength"
@input.native="inputHandle($event, isInteger, isZero, decimalCount)"
@blur="blurHandle"
></el-input>
</template>
<script>
export default {
name: "InputNumber",
inheritAttrs: false,
props: {
// 输入框的值
fieldValue: {
default: "",
},
// 输入最大长度限制
maxlength: {
type: String,
default: '15',
},
// 是否为整数
isInteger: {
type: Boolean,
default: true,
},
// 整数是否含0
isZero: {
type: Boolean,
default: true