假如我们需要的数值区间是(m,n)之间的随机整数 function num(m,n){ var nums=Math.floor(Math.random()*(m-n+1)+m) } 我们主要用到了js中的数学对象Math.floor()向下取整和Math.random()输出0到1之间的随机数。 亲爱的朋友学会了吗? 请关注敲代码的疯猫,会有小知识不定期更新呦