// 金额千分符格式化
export const stateFormat = (cellValue) => {
if (cellValue) {
cellValue += ''
if (!cellValue.includes('.')) cellValue += '.'
return cellValue
.replace(/(\d)(?=(\d{3})+\.)/g, ($0, $1) => {
return $1 + ','
})
.replace(/\.$/, '')
}
}
// 千分符反格式化
export const rmoney = (s) => {
let str = ''
if (s) {
str = String(s).replace(/,/g, '')
}
if (s && (s + '').indexOf('.') > -1 && Number(str)) {
return String(s).replace(/[^\d\.-]/g, '')
} else if (s && Number(str)) {
return str
} else {
return s
}
}
vue 金额千分符格式化和反格式化
最新推荐文章于 2024-06-08 16:02:30 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)