function uuidGenerator() {
var originStr = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
originChar = '0123456789abcdef',
len = originChar.length;
return originStr.replace(/x/g, function(match) {
return originChar.charAt(Math.floor(Math.random() * len))
})
}
console.log(uuidGenerator());
代码是从联想网站抄过来的。。。