We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
很多时候,数字显示的时候需要转换成千分位‘,’间隔;往往一般都是写一段算法来实现这个功能;
其实JS原生就是支持这么做的
//数字直接量 var num=123456789; nun.toLocaleString() //123,456,789 //或者是这样 123456789..toLocaleString() //123.456.789 //如果是输入框的内容 var s=$('').val() (+s).toLocaleString()
这样是不是简单很多
把数字转换成中文也可以用toLocaleString来实现;
//带逗号间隔 123456789..toLocaleString('zh-Hans-CN-u-nu-hanidec') //一二三,四五六,七八九 //不带逗号间隔 123456789..toLocaleString('zh-Hans-CN-u-nu-hanidec',{useGrouping:false})//一二三四五六七八九
The text was updated successfully, but these errors were encountered:
No branches or pull requests
很多时候,数字显示的时候需要转换成千分位‘,’间隔;往往一般都是写一段算法来实现这个功能;
其实JS原生就是支持这么做的
这样是不是简单很多
把数字转换成中文也可以用toLocaleString来实现;
The text was updated successfully, but these errors were encountered: