请教大神,如题
云函数get-hotline如下:
'use strict';
exports.main = async (event, context) => {
//event为客户端上传的参数
const db = uniCloud.database();//链接数据库
const collection = db.collection('hotline');
//返回数据给客户端
return collection.get()
};
前端页面如下:
<template>
<view>
<view v-for="(item,index) in list" :key="index">
<view>
<text>{{item.title}}</text>
<text>{{item.content}}</text>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
list: {
},
}
},
onLoad() {
this.getData()
},
methods: {
getData(){
uniCloud.callFunction({
name: 'get-hotline'
}).then(res=>{
// console.log(res);
return res.data
console.log(res.data)
})
}
}
}
</script>
<style>
</style>
1 个回复
cfan (作者)
已经自己解决了