账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    小程序 setData 重复执行?
    35
    0
    在执行pickAttribute()函数时,为什么changeNumber()增加了setData函数,changeNumber()函数会自动执行,且重复执行。逻辑上这两个函数是不发生关系的。pickAttribute: function (e) { if (this.data.tempOrder.count > 0 && this.data.goodsDetail.isAttribute) { console.log("968"); // this.checkingAttribute(); return }; if (this.data.tempOrder.count > 0 && !this.data.goodsDetail.isAttribute) { console.log("974"); this.setData({ showAttributes: true, }); return }; if (this.data.tempOrder.count <= 0) { console.log("982"); this.setData({ showAttributes: !this.data.showAttributes, }); return } },changeNumber: function (e) { const count = e.detail.count; console.log("count(640) => ", count); const bindType = e.detail.type; const enter = e.detail.enter; const goods = (enter === 'Detail') ? this.data.goodsDetail : e.detail.goods; const isAttribute = goods.isAttribute; const inList = this.data.goodsList.findIndex(item => { return item._id === goods._id }); if (!isAttribute) { this.setData({ [`goodsList${inList}.count`]: count, 'goodsDetail.count': count, }); console.log("goodsDetail(651) => ", this.data.goodsDetail); }; **//为什么加了这行代码会重复执行** //this.setData({ // 'tempOrder.count': count //}); console.log("tempOrder(656) => ", this.data.tempOrder); },
    0
    打赏
    收藏
    点击回答
        全部回答
    • 0
    更多回答
    网站公告
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部