uniapp 金额输入框
testMoney(e){let that = this;let price = e.detail.valueif (price.indexOf(".") == 0) {//'首位小数点情况'price = price.replace(/[^$#$]/g, "0.");pr...
·
<input class="ipt" type="digit" placeholder="输入金额" @input="testMoney" v-model="money"/>
testMoney(e){
let that = this;
let price = e.detail.value
if (price.indexOf(".") == 0) {
//'首位小数点情况'
price = price.replace(/[^$#$]/g, "0.");
price = price.replace(/\.{2,}/g, ".");
}
price = price.match(/^\d*(\.?\d{0,2})/g)[0] || null;
//重新赋值给input
this.$nextTick(() => {
this.money = price;
});
},
更多推荐
已为社区贡献1条内容
所有评论(0)