<template>
<div>
<input type="text" v-model="value" @input="inputFn" />
</div>
</template>
<script>
export default {
data() {
return {
value: "",
};
},
methods: {
inputFn() {
this.value = this.value
.replace(/[^/0-9.]/g, "")
.replace(/(\.d+)\.+/g, "$1")
.replace(/(\..*)\./g, "$1")
.match(/^\d*(\.?\d{0,2})/g)[0] || "";
},
},
};
</script>
<style>
</style>