怎样点击按键跳出循环?

小程序 文章 2020-08-18 12:01 702 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群

相关文章
【小建议】小程序能否隐藏request安全域名?
企业微信Android蓝牙通讯接受数据特别慢
ios14真机无法局域网调试
小程序的按钮图标,像这样的怎么改呢?
请问小程序在线客服可以实现用户指定客服人员吗?怎么实现?
随便看看
微信开放平台跟公众平台有什么区别? 3608
怎么添加小程序支付功能? 4516
教育科技公司申请微信支付被拒绝? 4798
微信公众号免300认证教程 5892
小程序已经上线,作为管理员无法在小程序数据助手查看数据? 5299
小程序广告组件通过审核,但是小程序内没有显示广告? 5067
企业微信通讯录账号被管理员误/恶意删除,怎么办? 9568
问题? 9048
如何快速搭建抽奖助手小程序(无需代码知识) 6177
许涛 大哥在吗, 要解冻小程序的时候提示信息主体不一致, 能帮忙看下吗? 7472