当前位置:网站首页>Amount input box, used for recharge and withdrawal
Amount input box, used for recharge and withdrawal
2022-04-23 17:49:00 【Sanxiaochi 513】
Encapsulate as a function , Hang up Vue On the prototype
// Amount input
function cash(e){
let price = e.toString()
// When you enter the decimal point directly, it is converted to '0.'
if(price.indexOf('.') == 0){
price = price.replace(/[^$#$]/g,'0.')
}
// First multiple 0 Turn into a
price = price.replace(/^0{1,}/g,'0')
// Convert consecutive decimal points into one
price = price.replace(/\.{2,}/g,'.')
// Only two decimal places
price = price.match(/^\d*\.?\d{0,2}/g)[0]
return price
}
Vue.prototype.$cash = cash
Listen for input events in the input box
input(e){
this.$nextTick(() => {
this.cash = this.$cash(e)
})
},
版权声明
本文为[Sanxiaochi 513]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230550325319.html
边栏推荐
- Summary of common server error codes
- [二叉数] 二叉树的最大深度+N叉树的最大深度
- 读《Software Engineering at Google》(15)
- 958. Complete binary tree test
- MySQL进阶之索引【分类,性能分析,使用,设计原则】
- In embedded system, must the program code in flash be moved to ram to run?
- Applet learning notes (I)
- Write a regular
- Detailed deployment of flask project
- 2022 judgment questions and answers for operation of refrigeration and air conditioning equipment
猜你喜欢
Halo 开源项目学习(二):实体类与数据表
Double pointer advanced -- leetcode title -- container with the most water
超分之TDAN
Advantages and disadvantages of several note taking software
练习:求偶数和、阈值分割和求差( list 对象的两个基础小题)
Flask项目的部署详解
极致体验,揭晓抖音背后的音视频技术
开源按键组件Multi_Button的使用,含测试工程
flink 学习(十二)Allowed Lateness和 Side Output
2021 Great Wall Cup WP
随机推荐
Summary of common server error codes
440. The k-th small number of dictionary order (difficult) - dictionary tree - number node - byte skipping high-frequency question
Uniapp custom search box adaptation applet alignment capsule
470. Rand10() is implemented with rand7()
Qt 修改UI没有生效
Leak detection and vacancy filling (6)
2022制冷与空调设备运行操作判断题及答案
Manually implement simple promise and its basic functions
列錶的使用-增删改查
198. Looting - Dynamic Planning
干货 | 快速抽取缩略图是怎么练成的?
JS get link? The following parameter name or value, according to the URL? Judge the parameters after
Oil monkey website address
2022 tea artist (primary) examination simulated 100 questions and simulated examination
122. The best time to buy and sell stocks II - one-time traversal
JS parsing and execution process
node中,如何手动实现触发垃圾回收机制
【Appium】通过设计关键字驱动文件来编写脚本
Sword finger offer 03 Duplicate number in array
Dry goods | how to extract thumbnails quickly?