<el-input v-model=”balanceRechargePrices” placeholder=”请输入充值金额” @input=”handleInput” @focus=”focusInput”></el-input>
const handleInput = (value: string) => {
console.log( value , value);
const restrictedValue = value.replace(/[^0-9.]/g, ).replace(/^./, );
// 限制小数点后最多两位
let limitedValue = restrictedValue.split( . ).length > 1 ? ${restrictedValue.slice(0, restrictedValue.indexOf( . ) + 3)} : restrictedValue;
limitedValue = limitedValue.replace(/(..*)./g, $1 );
balanceRechargePrice.value = limitedValue ? limitedValue : 0;
balanceRechargePrices.value = limitedValue ? limitedValue : ;
};
const focusInput = () => {
balanceRechargePrice.value = balanceRechargePrices.value;
};
© 版权声明
文章版权归作者所有,未经允许请勿转载。
相关文章
暂无评论...


