Angular项目生成使用随机数

Angular项目生成使用随机数

// 生成0~1的随机数并且保留一位小数
Number(Math.random().toFixed(1))
// 生成0~10的随机数,并且保留一位小数
Number((Math.random() * 10).toFixed(1))
// 生成0~100的随机数,并且不保留小数
Number((Math.random() * 100).toFixed(0))

就这样子。

原文地址:https://www.cnblogs.com/wjw1014/p/12703926.html