小程序-API请求

        Page({
            onLoad:function(){
                // 在onLoad中调用发送请求的函数
                this.getProList();
            }

            getProList:function(){
                var self=this;
                // 在这里向服务端发送请求
                wx.request({
                    url:"",
                    method:"GET",
                    success:function(res){
                        // 数据的赋值写在setData()方法里
                        self.setData({
                            proList:res.data
                        })
                    }
                })
            }
        })

猜你喜欢

转载自www.cnblogs.com/wuqilang/p/12076054.html