得到一定范围内的随机数

得到区间【m,n】之间的随机数

Math.round(Math.random()*(n-m)+m);

round方法会对括号内的数进行四舍五入

random方法会生成一个0到1之间的随机值

原文地址:https://www.cnblogs.com/frontendnotes/p/6446091.html