当前位置:网站首页>金额输入框,用于充值提现
金额输入框,用于充值提现
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
边栏推荐
猜你喜欢
File viewing commands and user management commands
Qt 给应用程序加图标
QT add qserialport class to realize serial port operation
CUDA environment installation
[UDS unified diagnostic service] IV. typical diagnostic service (2) - data transmission function unit
浮点数双精度,单精度以及半精度知识总结
【UDS统一诊断服务】五、诊断应用示例:Flash Bootloader
[UDS unified diagnostic service] i. overview of diagnosis (4) - basic concepts and terms
Initialization of classes and objects (constructors and destructors)
FOC电机库 定点PID代码分析
随机推荐
File viewing commands and user management commands
Vscode custom comments
2022LDU寒假训练-程序补丁
【UDS统一诊断服务】二、网络层协议(1)— 网络层概述与功能
PN结、二极管原理详解与应用
PM2 deploy nuxt related commands
[untitled]
C语言实现memcpy、memset、strcpy、strncpy、strcmp、strncmp、strlen
C#【文件操作篇】PDF文件和图片互相转换
赛氪-zeal
Quaternion multiplication
sqlite编译
软件工程中的十三种文档
C语言结构体指定初始化
C#【文件操作篇】按行读取txt文本
CUDA project encountered a series of compilation problems after changing the environment (computer)
Notes on advanced points of C language 4
Using printf in MFC
Log writing method (with time)
逻辑回归原理及代码实现