- 先下载所有db schema
- 在前端代码中直接访问数据库表拿数据
index.vue
<template>
<view class="content">
<view v-for="item in dataList" :key="item._id">
{{item.name}}---{{item.gender}}---{{item.age}}
</view>
</view>
</template>
<script>
// DB schema
const db = uniCloud.database()
export default {
data() {
return {
title: 'Hello',
dataList: [],
dataNum: 5
}
},
onLoad() {
this.getData();
},
methods: {
getData() {
db.collection("users").get().then(res => {
this.dataList = res.result.data
// console.log(res);
},
err => {
console.log(err.message);
})
}
}
}
</script>