收藏
回答

这个错误是由于引起的呢->查询参数对象值不能均为undefined?

云函数:
app.router('detail'async(ctx, next) => {
    let blogId = event.blogId  
    // 详情查询
    let detail = await blogCollection.where({
      _id: blogId
    }).get().then((res) => {
      return res.data  
    })
    // 评论查询
    const countResult = await blogCollection.count()  
    const total = countResult.total
    let commentList = {
      data: []
    }
    if (total > 0) {
      const batchTimes = Math.ceil(total / MAX_LIMIT)  
      const tasks = []
      for (let i = 0; i < batchTimes; i++) {
        let promise = db.collection('blog-comment').skip(i * MAX_LIMIT)
          .limit(MAX_LIMIT).where({
            blogId 
          }).orderBy('createTime''desc').get() 
        tasks.push(promise)
      }
      if (tasks.length > 0) {
        commentList = (await Promise.all(tasks)).reduce((acc, cur) => {  
          return {
            data: acc.data.concat(cur.data)
          }
        })
    }
  }
    ctx.body = {  /
      commentList,
      detail,
    }
  })


调用端函数:

onLoadfunction (options) {
    console.log(options)
    this._getBlogDetail(options.blogId)  
  },
_getBlogDetail(blogId){
  wx.showLoading({
    title: '加载中',
    true:true,
  })
  wx.cloud.callFunction({
    name :'blog',  
    data:{
      blogId,
      $url:'detail',  
    }
  }).then((res) =>{
    wx.hideLoading()
    console.log(res)


  })
},
回答关注问题邀请回答
收藏
登录 后发表内容
问题标签