num为传入的数字,n为需要的字符长度 return (Array(n).join(0) + num).slice(-n); 转载于:https://www.cnblogs.com/zhipeng007/p/11538520.html