// pages/shujuku/shujuku.js
Page({
data:{
list:[]
},
onLoad() {
console.log('启动啦')
wx.cloud.init({
env:'caull-5ghh6arc9f0f6913'
})
//es6的简介写法
wx.cloud.database().collection('goods') //拿到表。双引号也行
.where({//条件查询
name:'苹果'
})
.get()
.then(res=>{//请求成功
console.log('返回的数据',res)
this.setData({
list:res.data
})
})
.catch(err=>{//请求失败
console.log('请求失败',err)
})
},
})
<view wx:for="{{list}}">
<view>商品:{{item.name}}</view>
</view>