Math.random():用于获得一个0~1之间的小数,在此基础上可在封装一个函数来生成任意范围内的数字。 function random(min,max) { return Math.random()*(max-min)+min; }