当前位置:网站首页>金额输入框,用于充值提现
金额输入框,用于充值提现
2022-04-23 05:52:00 【三笑痴513】
封装成一个函数,挂到Vue原型上
// 金额输入
function cash(e){
let price = e.toString()
// 直接输入小数点时转化为'0.'
if(price.indexOf('.') == 0){
price = price.replace(/[^$#$]/g,'0.')
}
// 首位多个0转化成一个
price = price.replace(/^0{1,}/g,'0')
// 连续多个小数点转化成一个
price = price.replace(/\.{2,}/g,'.')
// 只能有两位小数
price = price.match(/^\d*\.?\d{0,2}/g)[0]
return price
}
Vue.prototype.$cash = cash
监听输入框的输入事件
input(e){
this.$nextTick(() => {
this.cash = this.$cash(e)
})
},
版权声明
本文为[三笑痴513]所创,转载请带上原文链接,感谢
https://blog.csdn.net/qq_60248719/article/details/123091209
边栏推荐
- [UDS unified diagnostic service] II. Network layer protocol (2) - data transmission rules (single frame and multi frame)
- Opencv uses genericindex for KNN search
- Object array and object pointer
- Understanding of SSH public key and private key
- C语言代码规范
- CUDA project encountered a series of compilation problems after changing the environment (computer)
- [UDS unified diagnosis service] i. diagnosis overview (3) - ISO 15765 architecture
- 友元函数,友元类,类模板
- C51/C52 特殊功能寄存器表
- Eigen 库常用基本用法 备忘
猜你喜欢
随机推荐
Vscode custom comments
cuda工程更换环境(电脑)后遇到的一系列编译问题
For() loop parameter call order
ARM常用汇编指令
Eigen 库常用基本用法 备忘
_findnext 报错
Log writing method (with time)
vs中的多字节与unicode
Make your own small program
QT add qserialport class to realize serial port operation
realsense 选型大对比D455 D435i D415 T265 3D硬件对比
Qt 给应用程序加图标
PM2 deploy nuxt related commands
[UDS unified diagnosis service] i. diagnosis overview (2) - main diagnosis protocols (K-line and can)
进程间通信-互斥锁
【UDS统一诊断服务】四、诊断典型服务(6)— 输入输出控制单元(0x2F)
SSH 公钥 私钥的理解
【UDS统一诊断服务】一、诊断概述(1)— 诊断概述
带默认模板实参的类模板与模板模板形参的匹配
Shell脚本 单引号、双引号和反引号的区别









