js 生成 uuid

2021-02-04  

/**
 * uuid
 */
uuid : function() {
	var originStr = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';//32位
    //var originStr = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx';//36位
	var originChar = '0123456789abcdef';
	var len = originChar.length;
	return originStr.replace(/x/g, function (match) {
		return originChar.charAt(Math.floor(Math.random() * len))
	})
}

 

ConstXiong 备案号:苏ICP备16009629号-3