+
95
-

微信小程序如何生成唯一的随机数uuid?

微信小程序如何生成唯一的随机数uuid?

网友回复

+
16
-

根目录下新建util.js

const wxuuid = function () {
  var s = [];
  var hexDigits = "0123456789abcdef";
  for (var i = 0; i < 36; i++) {
    s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
  }
  s[14] = "4"; // bits 12-15 of the time_hi_a...

点击查看剩余70%

+
15
-

随机函数的产生:

createNonceStr: function () {
     return Math.random()...

点击查看剩余70%

我知道答案,我要回答