js随机获取数组中的元素
解决方法:
假如qcollect是List集合对象
var i=Math.floor((Math.random()*array.length));
var obj=array[i]
补充说明:其中Math.random()可以得到0到1不包括1的数,Math.floor() 向下取整数。
向大家推荐《Activiti工作流实战教程》:https://xiaozhuanlan.com/activiti
js随机获取数组中的元素
解决方法:
假如qcollect是List集合对象
var i=Math.floor((Math.random()*array.length));
var obj=array[i]
补充说明:其中Math.random()可以得到0到1不包括1的数,Math.floor() 向下取整数。
有建议,请留言!