createUniqueString.js
386 Bytes
/**
* Created by jiachenpan on 17/3/8.
*/
// 获取随机字符串
export function getRandomString(length, chars) {
const len = length || 32;
const charStr = chars || '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
let result = '';
for (let i = len; i > 0; --i) { result += charStr[Math.floor(Math.random() * charStr.length)]; }
return result;
}