You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
14 lines
286 B
14 lines
286 B
|
3 years ago
|
/**
|
||
|
|
* @description: 获取指定位数的随机数
|
||
|
|
* @param {number} num
|
||
|
|
* @return {string}
|
||
|
|
* @example getRandom(4) // 0626
|
||
|
|
*/
|
||
|
|
export default function getRandom(num) {
|
||
|
|
let str = '';
|
||
|
|
for (let i = 0; i < num; i++) {
|
||
|
|
str += Math.floor(Math.random() * 10);
|
||
|
|
}
|
||
|
|
return str;
|
||
|
|
}
|