代码
function getShareToken(length) {var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';var shareToken = '';for (var i = 0; i < length; i++) {var randomIndex = Math.floor(Math.random() * characters.length);var randomChar = characters.charAt(randomIndex);shareToken += randomChar;}return shareToken;}
调用
console.log("share token====", getShareToken(8))
效果