var p= 10 //保留两位小数点 console.log(Math.round(p * 10000) /100) //js 随机数Math //1、0-x之间的随机数: Math.round(Math.random()*x); //2、x至y之间的随机数 Math.round(Math.random()*(y-x)+x); //3、1-x之间的随机数: Math.ceil(Math.random()*x);