微信小程序 云开发 数据库 请求数据

js:

data:{

listDatas:null//请求的数据存在这个数组里面

}

onLoad: function (options) {
  const db = wx.cloud.database();
  db.collection('otheritems').get().then(res => {//otheritems是数据库里面集合的名称
    console.log(res); //如果更新数据成功则输出成功信息
    var that = this;
    that.setData({
      listDatas: res.data
    });
    console.log(res.data);
  }).catch(err => {
    console.log(err); //如果更新数据失败则输出失败信息
  })
},

猜你喜欢

转载自www.cnblogs.com/lsyy2017/p/11568389.html