如果你对该文章中的内容有疑问/不解,可以点击此处链接提问
要注明问题和此文章链接地址 点击此处跳转
加载loading wx.showLoading({ title: '加载中', }) 关闭 loadingwx.hideLoading()
并行发送多个请求,使用promise.all
/** * 生命周期函数--监听页面加载 */ onLoad: function (options) { wx.showLoading({ title: '加载中', }) const bid = options.bid const detail = BookModel.getDetail(bid) const comments = BookModel.getComments(bid) const likeStatus = BookModel.getLikeStatus(bid) // ----组合多个------ Promise.all([detail,comments,likeStatus]) .then(res=>{ this.setData({ book:res[0], comments: res[1].comments, likeStatus: res[2].like_status, likeCount: res[2].fav_nums, }) }) wx:wx.hideLoading() // ---------- // detail.then(res=>{ // console.log(res) // this.setData({ // book:res // }) // }) // comments.then(res => { // console.log(res) // this.setData({ // comments: res.comments // }) // }) // likeStatus.then(res => { // console.log(res) // this.setData({ // likeStatus: res.like_status, // likeCount: res.fav_nums, // }) // }) },