js生成UUID

JS生成唯一的UUID:

function  getUUID() {
    return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
     
        var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
        return v.toString(16);
    });
}

 

posted @ 2020-12-09 10:17  Winton-H  阅读(383)  评论(0编辑  收藏  举报