將數字轉變成字符串的方法

一:使用數字自帶的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'
相關文章
相關標籤/搜索