uni-app unicloud-db 组件自动查询的问题
uni-app unicloud-db 组件自动查询的问题
| 信息类型 | 内容 |
|---|---|
| 产品分类 | uniCloud/App |
示例代码:
<uni-easyinput
v-model="searchForm.nickname"
placeholder="请输入用户昵称"
@input="handleSearch"
:clearable="true"
/>
<unicloud-db ref="udb" v-slot:default="{data, pagination, loading, hasMore, error}" collection="uni-id-users"
field="_id,nickname,avatar_file,mobile,role,username,email,status,last_login_date"
orderby="register_date desc"
:where="where"
:getcount="true"
:manual="true"
loadtime="manual"
>
computed: {
where() {
const where = {}
if (this.searchForm.nickname) {
where.nickname = new RegExp(this.searchForm.nickname, 'i')
}
if (this.searchForm.role) {
where.role = this.searchForm.role
}
return where
}
},
操作步骤:
直接参考上边的代码示例
预期结果:
直接参考上边的代码示例
实际结果:
直接参考上边的代码示例
bug描述:
当 db 组件设置了 :manual="true" 时,如果同时设置了 where 为一个计算属性,那么当计算属性变化时,db组件还是会自动查询,manual属性不生效,如果使用最新的属性 loadtime="manual" ,则恢复正常。由于manual属性在部分官方示例中依然在使用(例如uni-starter),所以还是有必要修复一下的。
更多关于uni-app unicloud-db 组件自动查询的问题的实战教程也可以访问 https://www.itying.com/category-93-b0.html
manual=“true” 定义是 仅在 onReady 后是否自动加载数据,后续属性变更时不影响
loadtime 可以指定 auto/onready/manual 如果指定为 manual 时永不会自动加载数据,即使属性发生变化
两者的功能不同,后者更具体些
manual=“true” 不能调整现有逻辑,会引发开发者代码兼容问题,我们排查下现有示例的旧写法
更多关于uni-app unicloud-db 组件自动查询的问题的实战教程也可以访问 https://www.itying.com/category-93-b0.html
按照文档上来说,manual 设置为true时,组件就不会自动加载了,但是当组件的where是一个计算属性时,他就会自动加载。(并没有调用 this.$refs.udb.loadData() 方法,你可以测试下 )
回复 奔跑吧阿虎: 是这个逻辑,仅在 onReady 生命周期生效一次,引用文档: manual=“true” 已过时,使用 loadtime 替代 是否手动加载数据,默认为 false,页面onready时自动联网加载数据

