sharno
sharno
  • 发布:2021-11-23 15:07
  • 更新:2021-11-23 19:49
  • 阅读:1075

【报Bug】unicloud-db 经常无法正常渲染数据

分类:uniCloud

产品分类: uniCloud/App

操作步骤:
   <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>

预期结果:

正确渲染不报错

实际结果:

报错内容

 [Vue warn]: Error in onready hook: "TypeError: Cannot read property 'selectAllComponents' of null"  

(found in pages/goods/index.vue)(env: Windows,mp,1.05.2111162; lib: 2.21.0)  
warn @ vendor.js?t=wechat&s=1637650298455&v=30d98053499f75b286ba27d029673996:2703  
Vue.config.errorHandler @ vendor.js?t=wechat&s=1637650298455&v=30d98053499f75b286ba27d029673996:7896  
globalHandleError @ vendor.js?t=wechat&s=1637650298455&v=30d98053499f75b286ba27d029673996:3966  
handleError @ vendor.js?t=wechat&s=1637650298455&v=30d98053499f75b286ba27d029673996:3935  
invokeWithErrorHandling @ vendor.js?t=wechat&s=1637650298455&v=30d98053499f75b286ba27d029673996:3958  
Vue.__call_hook @ vendor.js?t=wechat&s=1637650298455&v=30d98053499f75b286ba27d029673996:7953  
_vue.default.__call_hook @ vendor.js?t=wechat&s=1637650298455&v=30d98053499f75b286ba27d029673996:1466  
mpOptions.<computed> @ vendor.js?t=wechat&s=1637650298455&v=30d98053499f75b286ba27d029673996:896  
N @ VM577 WAService.js:2  
(anonymous) @ VM577 WAService.js:2  
(anonymous) @ VM577 WAService.js:2  
(anonymous) @ VM577 WAService.js:2  
(anonymous) @ VM577 WAService.js:2  
c @ VM13 asdebug.js:1  
l @ VM13 asdebug.js:1  
(anonymous) @ VM13 asdebug.js:1  
g @ VM13 asdebug.js:1  
f @ VM13 asdebug.js:1  
(anonymous) @ VM13 asdebug.js:1  
_ws.onmessage @ VM13 asdebug.js:1  
vendor.js?t=wechat&s=1637650298455&v=30d98053499f75b286ba27d029673996:7897 TypeError: Cannot read property 'selectAllComponents' of null  
    at selectAllComponents (vendor.js?t=wechat&s=1637650298455&v=30d98053499f75b286ba27d029673996:1646)  
    at vendor.js?t=wechat&s=1637650298455&v=30d98053499f75b286ba27d029673996:1653  
    at Array.forEach (<anonymous>)  
    at vendor.js?t=wechat&s=1637650298455&v=30d98053499f75b286ba27d029673996:1652  
    at Array.forEach (<anonymous>)  
    at selectAllComponents (vendor.js?t=wechat&s=1637650298455&v=30d98053499f75b286ba27d029673996:1647)  
    at VueComponent.get [as $refs] (vendor.js?t=wechat&s=1637650298455&v=30d98053499f75b286ba27d029673996:1665)  
    at VueComponent.onPullDownRefresh (vendor.js?t=wechat&s=1637650298455&v=30d98053499f75b286ba27d029673996:12707)  
    at invokeWithErrorHandling (vendor.js?t=wechat&s=1637650298455&v=30d98053499f75b286ba27d029673996:3950)  
    at VueComponent.Vue.__call_hook (vendor.js?t=wechat&s=1637650298455&v=30d98053499f75b286ba27d029673996:7953)(env: Windows,mp,1.05.2111162; lib: 2.21.0)

bug描述:

使用unicloud-db 渲染1个列表, 经常出现不渲染状态 ,根据错误提示预计是 组件内部 使用了$refs, 但由于时机不正确,导致返回null,就无法正确渲染页面, db的请求和返回数据都正常,就是渲染不出来

2021-11-23 15:07 负责人:无 分享
已邀请:
DCloud_uniCloud_WYQ

DCloud_uniCloud_WYQ

在manifest内配置对应平台下的scopedSlotsCompiler为augmented试试

  • sharno (作者)

    试了一下,好像没有出现了, 但不敢在试了,搞了1天,还是用传统方式吧

    2021-11-23 21:24

  • 毛绒绒的大腿

    回复 sharno: 同样的问题,刚开始用unicloud-db,经常会出现页面数据没加载出来,各种奇怪的报错,unicloud-db只是简化写代码的方式,对开发人员来说。还是用之前的逻辑和思维方式来做吧。别被unicloud-db带偏了

    2021-12-24 14:36

该问题目前已经被锁定, 无法添加新回复