当前位置:网站首页>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
边栏推荐
猜你喜欢

Double pointer advanced -- leetcode title -- container with the most water

2021 Great Wall Cup WP

440. The k-th small number of dictionary order (difficult) - dictionary tree - number node - byte skipping high-frequency question

超分之TDAN

2022制冷与空调设备运行操作判断题及答案

PC uses wireless network card to connect to mobile phone hotspot. Why can't you surf the Internet

Qt error: /usr/bin/ld: cannot find -lGL: No such file or directory

On the problem of V-IF display and hiding
MySQL installation

MySQL进阶之索引【分类,性能分析,使用,设计原则】
随机推荐
20222 return to the workplace
JVM类加载机制
Qt error: /usr/bin/ld: cannot find -lGL: No such file or directory
402. Remove K digits - greedy
Utilisation de la liste - Ajouter, supprimer et modifier la requête
Future 用法详解
ros常用的函数——ros::ok(),ros::Rate,ros::spin()和ros::spinOnce()
uni-app黑马优购项目学习记录(下)
给 el-dialog 增加拖拽功能
嵌入式系统中,FLASH中的程序代码必须搬到RAM中运行吗?
958. Complete binary tree test
This point in JS
Type judgment in [untitled] JS
958. 二叉树的完全性检验
Ring back to origin problem - byte jumping high frequency problem
JS get link? The following parameter name or value, according to the URL? Judge the parameters after
386. Dictionary order (medium) - iteration - full arrangement
剑指 Offer 03. 数组中重复的数字
ES6 new method
102. 二叉树的层序遍历