- 获取不重复的随机数算法
[图片] 参数count:获取随机数的个数 参数total:总共的个数 返回值:随机的数组 randomtimu: function (count,total){ var sequence = new Array(total) var output = new Array(count) [代码]for (let i = 0; i < total; i++) { sequence[i] = i } let end = total - 1 for (let i = 0; i < count; i++) { var num = Math.floor(Math.random() * (end + 1)) output[i] = sequence[num] sequence[num] = sequence[end] end-- } return output [代码] },
2019-05-18 - scene扫码取值,decodeURIComponent不会用的看过来
[代码]if[代码] [代码](JSON.stringify(option) !== [代码][代码]'{}'[代码] [代码]&& option.scene !== undefined) {[代码][代码] [代码][代码]let scene = decodeURIComponent(option.scene);[代码][代码] [代码][代码]let sceneData = {};[代码][代码] [代码][代码]scene.split([代码][代码]'&'[代码][代码]).forEach(item => {[代码][代码] [代码][代码]sceneData[item.split([代码][代码]'='[代码][代码])[0]] = (item.split([代码][代码]'='[代码][代码])[1]);[代码][代码] [代码][代码]})[代码][代码] [代码][代码]console.log([代码][代码]'scene'[代码][代码], sceneData);[代码][代码] [代码][代码]}[代码]
2019-04-03