<unicloud-db v-slot:default="{data, loading, hasMore, error}"
ref="udb"
:where="where"
collection="uni-id-users"
loadtime="onready"
field="_id,username,mobile,role">
<u-cell-group title="用户列表">
<u-cell-item v-for="(item,index) in data"
:key="item._id"
:title="item.username"
:label="item.mobile"
:arrow="false">
<u-button v-if="!!item.role.length" @click="onChangeRole(item,index)" type="error" size="mini">禁用</u-button>
<u-button v-else type="success" @click="onChangeRole(item,index)" size="mini">通过</u-button>
</u-cell-item>
</u-cell-group>
</unicloud-db>
<script>
import mixinPage from '@/common/mixins/mixinPage.js'
const db = uniCloud.database();
export default {
mixins: [mixinPage],
data() {
return {
tabIndex: 0,
where: "",
tabList: [{
name: '所有',
where: "!(role in ['AUDITOR','admin'])"
}, {
name: '待审核',
where: 'size(role) == 0'
}, {
name: '已审核',
where: "role == 'USER'"
}]
}
},
onReady() {
this.onChangTab()
},
methods: {
onChangTab(index = 0) {
this.tabIndex = index
this.where = this.tabList[index].where
},
onChangeRole(item, index) {
}
}
}
</script>
sharno (作者)
试了一下,好像没有出现了, 但不敢在试了,搞了1天,还是用传统方式吧
2021-11-23 21:24
毛绒绒的大腿
回复 sharno: 同样的问题,刚开始用unicloud-db,经常会出现页面数据没加载出来,各种奇怪的报错,unicloud-db只是简化写代码的方式,对开发人员来说。还是用之前的逻辑和思维方式来做吧。别被unicloud-db带偏了
2021-12-24 14:36