button中使用了loading,当做子组件使用,父组件中出现了异常情况?

小游戏 企业微信 微信支付 小程序 文章 2020-07-30 21:23 616 0 全屏看文

AI助手支持GPT4.0

button中使用了loading,当做子组件使用,父组件中出现了异常情况?

这样写,在数据变化过程中,只是操作了两次赋值,最终data中值,已经变化了,但是页面未变动。比如刚开始都是0,变化成1,接着变化为0,data中数据已经变化,但是页面从0变化到1之后,返回不到0了


In this way, in the process of data change, only two assignments are performed. Finally, the median value of the data has changed, but the page has not changed. For example, the data in the data has changed from 0 to 1 at the beginning, and then to 0. However, after the page changes from 0 to 1, it can not return to 0

回答:

琦点:
changeEditor({detail}) {    let {selfFiles, upqueuelenth,index} = this.data    let queuelenthNum = parseInt(detail.queuelenth)    let that = this    // 第一次触发的时候,显示加载动画    if (upqueuelenth == 0 && queuelenthNum != 0) {        if(index==0){            that.setData({   listData: detail.listData,   selfFiles: Object.assign(that.data.selfFiles, detail.selfFiles),   upqueuelenth: 1,   index:index+1            })        }else {            let timer=setTimeout(function () {   that.setData({       listData: detail.listData,       selfFiles: Object.assign(that.data.selfFiles, detail.selfFiles),       upqueuelenth: 1,       index:index+1   })   clearTimeout(timer)            },0)        }    }    //最后一次触发的时候,隐藏动画加载    if (upqueuelenth == 1 && queuelenthNum == 0) {        let timer=setTimeout(function () {            that.setData({   listData: detail.listData,   selfFiles: Object.assign(that.data.selfFiles, detail.selfFiles),   upqueuelenth: 0            })            clearTimeout(timer)        },0)    }},


琦点:我这边解决思路见上,已经解决了
LeeJim🌀:

很典型的组件封装问题,可以看看我写的文章:https://developers.weixin.qq.com/community/develop/article/doc/000ea0162bce70c8c62a40de156413

琦点:看了下,应该不是传值的问题。已经做到开始及最后一次传值的控制了

-EOF-

AI助手支持GPT4.0