οninput="value=value.replace(/^0[0-9]+/,val=>val[1]).replace(/^(\.)+/,'').replace(/[^\d.]/g,'').replace(/\.+/,'.').replace(/^(\-)*(\d+)\.(\d\d).*$/,'$1$2.$3')"
<template>
<div>
<el-input
v-model="form.value"
@input="form.value = inputCheck(form.value)"
/>
<router-view />
</div>
</template>
<script>
export default {
data() {
return {
value: '',
form: {
value: ''
}
};
},
methods: {
inputCheck(value) {
return value
.replace(/^0[0-9]+/, val => val[1])
.replace(/^(\.)+/, '')
.replace(/[^\d.]/g, '')
.replace(/\.+/, '.')
.replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3');
}
}
};