将数字转变成字符串的方法

一:使用数字自带的API toFixed(num): –toFixed()表示将数字转换为字符串,在转换后的字符串中,小数点后保留指定num位的小数。web 使用方法:svg let a = 15.56; a.toFixed(); //'16' a.toFixed(1); //'15.6' a.toFixed(2); //'15.56' a.toFixed(5); //'15.56000'
相关文章
相关标签/搜索