微信小程序后台获取数据刷新页面

1.获取数据方法:

let that =this;
        wx.request({
            url: baseUrl + "/processRecord/sectionlist",
            data: {
                openid: '',
                uuid: ''
            },
            method: 'Get',
            header: {
                //'content-type': 'application/json' // 默认值
                //'Content-Type': 'application/x-www-form-urlencoded'
            },
            success: function (res) {
              
            },
            fail: function (e) {
             
            }
        })

2.刷新方法:

在request方法前面设立当前上下文引用,因为在request方法里面this已经变成了方法内的上下文,这种情况下需要调用外部的上下文方法,所以在方法之前需要添加let that =this;

sucess方法里面的写法:

this.data.****
that.data.****
that.setData({});

 

posted @ 2022-05-05 10:59  Shapley  阅读(1500)  评论(0编辑  收藏  举报