1. 字符串格式化
var hot_li_template = ‘<li><div class="li-out"><span class="last"><i>{0}</i></span><span class="name"><a ?href="{1}">{2}</a></span><span class="nums">{3}</span></div></li>‘jQuery.format(hot_li_template, i + 1, url, data.title, numberScale(data.views));
ƒ (num) { ???var ret = num; ???if (num > 1000) { ???????ret = (num / 1000).toFixed(1) + ‘k‘; ???} ???return ret;}
toFixed() 方法可把 Number 四舍五入为指定小数位数的数字。
Jquery
原文地址:https://www.cnblogs.com/yangfei-beijing/p/8178919.html