当前位置:网站首页>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
边栏推荐
猜你喜欢
Operation of 2022 mobile crane driver national question bank simulation examination platform
394. 字符串解码-辅助栈
JVM类加载机制
Flask项目的部署详解
编译原理 求first集 follow集 select集预测分析表 判断符号串是否符合文法定义(有源码!!!)
STM32 entry development board choose wildfire or punctual atom?
Qt error: /usr/bin/ld: cannot find -lGL: No such file or directory
2022 judgment questions and answers for operation of refrigeration and air conditioning equipment
Dry goods | how to extract thumbnails quickly?
Gaode map search, drag and drop query address
随机推荐
Double pointer advanced -- leetcode title -- container with the most water
470. Rand10() is implemented with rand7()
Sword finger offer 03 Duplicate number in array
Compilation principle first set follow set select set prediction analysis table to judge whether the symbol string conforms to the grammar definition (with source code!!!)
Write a regular
[二叉数] 二叉树的最大深度+N叉树的最大深度
编译原理 求first集 follow集 select集预测分析表 判断符号串是否符合文法定义(有源码!!!)
Tdan over half
122. 买卖股票的最佳时机 II-一次遍历
Ring back to origin problem - byte jumping high frequency problem
PC电脑使用无线网卡连接上手机热点,为什么不能上网
Halo 开源项目学习(二):实体类与数据表
uni-app黑马优购项目学习记录(下)
Arithmetic expression
Leak detection and vacancy filling (6)
Leak detection and vacancy filling (VIII)
Halo 开源项目学习(二):实体类与数据表
Manually implement simple promise and its basic functions
Entity Framework core captures database changes
MySQL installation