大兄弟最后这个怎么解决的
有人遇到过_this.setData is not a function报错吗代码如下,报错地方代码为红色标注出来的部分: sendMsg:function(){ let that = this; let time=60; /*改变按钮可点击状态 */ this.setData({ isSend:false }); /* 倒计时 */ let timer=setInterval(()=>{ if(time==0){ clearInterval(timer); this.setData({ isSend:true, sendMsg:'重新发送' }); }else{ time--; this.setData({ isSend:false, sendMsg:time+'秒后重新发送' }); } },1000); /* 发送短信 */ wx.request({ url:'https://XXXXXXXXXXX', method:'POST', data: { 'phone': phone }, header: { 'content-type': 'application/x-www-form-urlencoded' }, success: function(res) { if(!!res.data.code || res.data.code==0){ if(res.data.code!=1){ wx.showModal({ title: '提示', content: res.data.message, }); clearInterval(timer); that.setData({ isSend:true, sendMsg:'重新发送' }); } }else{ clearInterval(timer); that.setData({ isSend:true, sendMsg:'重新发送' }); } }, fail:function(res){ clearInterval(timer); that.setData({ isSend:true, sendMsg:'重新发送' }); } }); } 报错如下: [图片] 然后把报错部分的this也修改成用that替换,还是报错 [图片]
2024-03-11