wxml:
<button type="primary" bindtap="getDataFromBuyerBasics">获取数据</button>
<view wx:for="{{dataArray}}" wx:key="index">{{index+1}}-{{item.buyerName}}</view>
wxss:
page{
padding: 10rpx;
box-sizing: border-box;
}
view{
border: 1px solid #000;
}
js:
// 连接微信云数据库
const db = wx.cloud.database()
Page({
data: {
"dataArray":""
},
// 获取buyerBasics的数据
getDataFromBuyerBasics(){
db.collection("buyerBasics")
.limit(3)
.get()
.then(res=>{
console.log(res.data)
this.setData({
"dataArray":res.data
})
})
},
onLoad: function (options) {
}
})
前端效果图:
后端运行结果: