// pages/Second/Second.js var app = getApp() var Paths = ['曾恬灵','龙思怡', '杨光正 ', '张嘉威', '李玲', '程方磊','陈佳慧','张定坚','吴世胜','黄益民','刘燕玲','赵金改']; //随机滚动的名字序列 var Index = 0; //初试默认为0 Page({ /** * 页面的初始数据 */ data: { Path:Paths[0], title:'Start', //设按钮文字为Start isRunning:false, userInfo:{}, }, bindViewTap:function(){ wx.navigateTo({ url: '../logs/logs', }) }, change:function(e){ Index++; //当Index>6时,Index=0,即当滚动到最后一个名字时,从头开始滚动,这个数值根据Paths中名字的个数改变 if (Index>6){ Index=0; } this.setData( { Path:Paths[Index] } ) }, guess:function(e){ let isRunning = this.data.isRunning; if(!isRunning){ this.setData( { title:'Stop', //按钮上的字变为Stop isRunning:true } ); this.timer=setInterval((function(){ this.change() }).bind(this),50 ); //名字滚动的频率 } else{ this.setData( { title:'Start', //按钮上的字变为StART isRunning:false } ); this.timer&&clearInterval(this.timer); } } })