/**
* 获取指定随机数
* randomNumer(最大值,最小值,保留几位小数)
*/
export function randomNumer(maxNum, minNum, decimalNum) {
// 获取指定范围内的随机数, decimalNum指小数保留多少位
var max = 0,
min = 0;
minNum <= maxNum ? (min = minNum, max = maxNum) : (min = maxNum, max = minNum);
switch (arguments.length) {
case 1:
return Math.floor(Math.random() * (max + 1));
break;
case 2:
return Math.floor(Math.random() * (max - min + 1) + min);
break;
case 3:
return (Math.random() * (max - min) + min).toFixed(decimalNum);
break;
default:
return Math.random();
break;
}
}