<template>
<view style="padding: 200rpx">
<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;
if((e.target.value + '').startsWith("00")){
e.target.value = 0
}
//重新赋值给input
this.$nextTick(() => {
this.money = e.target.value;
});
},
},
};
</script>
uniapp小程序金额输入框限制
最新推荐文章于 2024-08-05 19:34:03 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)