<template>
<view>
<input v-model="money" type="number" @input="check" placeholder="金额(元)" />
</view>
</template>
<script>
export default {
data() {
return {
money:''
}
},
methods: {
check: function(e) {
//正则表达试
e.target.value = (e.target.value.match(/^\d*(\.?\d{0,2})/g)[0]) || null
//重新赋值给input
this.$nextTick(() => {
this.money= e.target.value
})
},
},
}
</script>
<style>
</style>
uniapp限制输入两位小数点-价格金额demo效果(整理)
猜你喜欢
转载自blog.csdn.net/qq_38881495/article/details/129464975
今日推荐
周排行