这个怎么控制每个的概率啊?
document.onkeydown = function(event) { var e = event || window.event || arguments.callee.caller.arguments[0]; if (e && e.keyCode == 32) { // enter 键 $('showSweetAlert').css("display","none");$('sweet-overlay').css("display","none");if(bRotate)return;var item = rnd(1,5);switch (item) {case 1://var angle = [26, 88, 137, 185, 235, 287, 337];rotateFn(1, 55, '888元');break; case 2://var angle = [88, 137, 185, 235, 287];rotateFn(2, 140, '388元');break;case 3://var angle = [137, 185, 235, 287];rotateFn(3, 199, '188元');break;case 4://var angle = [137, 185, 235, 287];rotateFn(4, 269, '88元'); break;case 5://var angle = [185, 235, 287];rotateFn(5, 341, '8元');break;}console.log(item); } }; $('.pointer').click(function (){if(bRotate)return;var item = rnd(1,5);switch (item) {case 1://var angle = [26, 88, 137, 185, 235, 287, 337];rotateFn(1, 55, '888元');break;case 2://var angle = [88, 137, 185, 235, 287]; rotateFn(2, 140, '388元');break;case 3://var angle = [137, 185, 235, 287];rotateFn(3, 199, '188元');break;case 4://var angle = [137, 185, 235, 287];rotateFn(4, 269, '88元');break;case 5://var angle = [185, 235, 287]; rotateFn(5, 341, '8元');break;}console.log(item);});});function rnd(n, m){return Math.floor(Math.random()*(m-n+1)+n)}回复