✨Function that generates names of specified length
- ⌛ Usage scenario: When uploading pictures or saving files, you can use this function when you need the front-end to generate unique file names.
- ⏳ Input parameter: length, the length of the string that needs to be generated
- ⌛ Return value {string} random string, eg:13y32hbrhj
randomString(length) {
const str = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
let result = '';
for (let i = length; i > 0; --i)
result += str[Math.floor(Math.random() * str.length)];
return result;
},