怎样点击按键跳出循环?

小程序 文章 2020-08-18 12:01 596 0 全屏看文

AI助手支持GPT4.0

怎样点击按键跳出循环?How to click the button to jump out of the loop?

怎样点击按键跳出循环?
 点击按键stop,start按键获取不了m值,导致跳不出循环,有没有更理想的办法?1、index.js   Page({bindinput: function (e) {    this.setData({      userName: e.detail.value    })  },start: function () {     var m=this.data.m console.log('m------//',m)    for (var i = 0; i < 6; ++i) {        console.log('bhtime------//',i)       if (i==5){var i=0}    this.setData({      userName: i    })  if(m==5break;}     },  stop: function () {         console.log('stop')           this.setData({      m: 5    })       },})2、index.wxml     class=   "button1" catchtap=   "start">start        class=    "button2" catchtap=    "stop">stop          class=     "c">                class=      "check-box"  maxlength=      '10'  value=      "{{userName}}"       type=      "text" bindinput=      'bindinput' >              

Click the stop button, the start button can not get the m value, resulting in the loop can not jump out, is there a better way? 1、 index.js    Page({bindinput: function (e) {     this.setData ({      userName: e. detail.value     })  },start: function () {     var m= this.data .m  console.log ('m------//',m)    for (var i = 0; i < 6; ++i) {         console.log ('bhtime------//', i)       if (i==5){var i=0}     this.setData ({      userName: i    })  if(m==5) break;}     },  stop: function () {          console.log ('stop')            this.setData ({      m: 5    })       }, })2、 index.wxmlclass= "button1" catchtap="start">start class="button2" catchtap="stop">stop class="c">class="check-box"  maxlength='10'  value="{{userName}}" type="text" bindinput='bindinput' >

回答:

Sven scum་ཅ་:

把循环封装,点击按键调用封装你的循环进行中断


微喵网络:

弄一个 [ 能复现问题的简单的 ] 代码片段

https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html

stop eating:

这是什么功能?写着玩的?

-EOF-

AI助手支持GPT4.0


国内超级便宜服务器

摸鱼人热门新闻聚合

钻级赞助商 我要加入

开发者在线工具

第三方支付技术请加QQ群

相关文章
微信网页开发 JSSDK 分享功能,安卓和调试工具都成功,IOS无法使用?
企业微信内H5网页分享微信好友ios正常安卓自定义标题、图标、未生效
微信小游戏内部转充开票问题?
Compoent 中 数组数据显示[object object]
小程序2M大小限制,能提升下吗?太小了了。图片都放到服务器了。就代码超过2M。太小了
随便看看
企业微信通讯录账号被管理员误/恶意删除,怎么办? 8026
问题? 7260
如何快速搭建抽奖助手小程序(无需代码知识) 5045
许涛 大哥在吗, 要解冻小程序的时候提示信息主体不一致, 能帮忙看下吗? 5998
小程序搜一搜全称搜索不显示 麻烦解决一下!谢谢 5515
我的小程序广告收款主体是个体工商户,每个月邮寄两次发票很是麻烦,我年底的时候打包邮寄一次可以么? 5209
如何解决渲染层网络错误Failed to load media? 16563
小程序找号找回 释放昵称? 2426
我的小程序广告主收入5301,实际进账4406,是怎么回事呀? 2508
删除部分微信用户个人数据的通知,怎么删除? 5555