当前位置:网站首页>js数字大写方法
js数字大写方法
2022-04-23 05:36:00 【晴天暖宝宝】
js实现数字大写的方法:
capitalMoney(num) {
var strOutput = '';
var strUnit = '仟佰拾亿仟佰拾万仟佰拾元角';
num += '0';
var intPos = num.indexOf('.');
if (intPos >= 0) {
num = num.substring(0, intPos) + num.substr(intPos + 1, 1);
}
strUnit = strUnit.substr(strUnit.length - num.length);
for (var i = 0; i < num.length; i++) {
strOutput +=
'零壹贰叁肆伍陆柒捌玖'.substr(num.substr(i, 1), 1) +
strUnit.substr(i, 1);
}
return strOutput
.replace(/零角$/, '整')
.replace(/零[仟佰拾]/g, '零')
.replace(/零{2,}/g, '零')
.replace(/零([亿|万])/g, '$1')
.replace(/零+元/, '元')
.replace(/亿零{0,3}万/, '亿')
.replace(/^元/, '零元');
}
版权声明
本文为[晴天暖宝宝]所创,转载请带上原文链接,感谢
https://blog.csdn.net/txun123/article/details/124357281
边栏推荐
- Various situations of data / component binding
- Flutter nouvelle génération de rendu graphique Impeller
- Deep learning object detection
- Getting started with varnish
- Error handling mechanism of the strongest egg framework in history
- Edit, cancel, pull up menu
- Click the Add button - a box appears (similar to adding learning experience - undergraduate - Graduate)
- Executable program execution process
- Golang通过exec模块实现Ping连通性检测案例
- Common interview questions - 4 (MySQL)
猜你喜欢
The title bar will be pushed to coincide with the status bar
Cross domain CORS relationship~
Hongji cyclone RPA provides technical support for Guojin securities and realizes process automation in more than 200 business scenarios
弘玑|数字化时代下,HR如何进行自我变革和组织变革?
Uncle wolf is looking for a translator -- Plato -- ongoing translation
On the use of constant pointer and pointer constant -- exercise (record)
Create cells through JS (while loop)
es6数组的使用
what is wifi6?
Breadth first search topics (BFS)
随机推荐
deep learning object detection
OSI层常用协议
Use of ES6 array
Three methods of list rendering
CORS and proxy (づ  ̄ 3  ̄) in egg ~ the process of stepping on the pit and filling the pit ~ tot~
Pol / select / EPO
Introduction to qqueue
Qwebsocket communication
3d slicer中拉直体的生成
相机成像+单应性变换+相机标定+立体校正
Flutter 新一代图形渲染器 Impeller
String class understanding - final is immutable
Note: unordered_ Understanding and use of map
Sword finger offer II 022 The entry node of the link in the linked list
Log introduction and building web application
Reading notes of modern methods of C language programming
Error handling mechanism of the strongest egg framework in history
Flutter nouvelle génération de rendu graphique Impeller
JSON.
C# ,类库