html52.com
我爱小程序-开发者交流社区

在onload里面写查数据库,查询结果却在onready之后,求大佬讲解一下

问题模块 框架类型 问题类型 终端类型 AppID 基础库版本
云开发 小程序 Bug 客户端 wx52213d3cefee9913 2.2.5

如下图所示,在onload里写的查数据库的方法,却在onready之后打印出结果

具体方法如下:具体方法如下:

  onLoad:function(options){

    this.searchInfo()

  },

searchInfo:function(){

    console.log("onshow....")

    const db = wx.cloud.database()

    console.log("onshow111")

    db.collection('problem').where({

      _openid: this.data.openid,

    }).get({

      success: res => {

        this.setData({

          items: JSON.stringify(res.data, null, 2)

        })

        console.log("123:", this.data.items)

      },

      fail: err => {

        wx.showToast({

          icon: 'none',

          title: '查询记录失败'

        })

      }

    })

  }



网友回复

半寸灰:

查询结果异步操作  需要一定的时间的


评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

真正的个人免签约支付接口

云免签H5支付