微信小程序---笔记

1.初始化数据将作为页面的第一次渲染。data 将会以 JSON 的形式由逻辑层传至渲染层,所以其数据必须是可以转成 JSON 的格式:字符串,数字,布尔值,对象,数组。

  1. 用户刷新事件使用
    onPullDownRefresh:function(){ onPullDownRefresh:function(){
    // 用户刷新事件,
    var that = this;
    wx.request({
    // 刷新时发送请求
    url: ‘https://api.eawsp.com/api/creditCard/getCreditCardImg’, //仅为示例,并非真实的接口地址
    data: {
    },
    method: “POST”,
    header: {
    “Content-Type”: “application/x-www-form-urlencoded” //post
    },
    success: function (res) {
    if (res.data.code == 0) {
    console.log(res.data.data.data);
    that.setData({
    card: res.data.data.data
    })
    }
    }
    })
    wx.stopPullDownRefresh();
    // 结束刷新
    }

猜你喜欢

转载自blog.csdn.net/weixin_39815001/article/details/84633442