/** * JS生成唯一的ID * @method guid * @grammar Base.guid() => String * @grammar Base.guid( prefx ) => String */ function guid(prefix) { var counter = 0; var guid = (+new Date()).toString(32), i = 0; for (; i < 5; i++) { guid += Math.floor(Math.random() * 65535).toString(32); } return (prefix || 'guid_') + guid + (counter++).toString(32); } console.log(guid()); console.log(guid()); console.log(guid('code.cent123.com_'));
JS生成唯一的ID
JavaScript
2021-05-26
admin
1210
1633
如果文章对您有帮助,点击下方的广告,支持一下作者吧!
转载必须注明出处: