Get random number
js取随机数看这里
取0~10的随机数
Math.Random()*10 ;
取1~10的随机数
Math.Random()*9 + 1 ;
取0~10的随机整数(十一个数字)
Math.floor( Math.Random()*11) ;
取1~10的随机整数
Math.floor( Math.Random()*10 + 1 ) ; Math.ceil( Math.Random()*10 ) ; // 当需要从1开始取随机整数时,使用向上取整
总结:取a~b整数写法的公式(a,b为整数,且需同时取到a,b):
Math.floor( Math.Random() * ( b-a+1 ) + a ) ;

浙公网安备 33010602011771号