从数据库请求数据到显示内容之间页面会有一段空白
为了提高用户体验
可以在页面内容出现之前先显示loading状态
等页面内容全部渲染完后再隐藏loading
代码如下
onLoad: function (options) {var that = this;wx.showLoading({title: '加载中',})var db = wx.cloud.database();db.collection("subject").get().then(res =>{console.log(res)that.setData({ movie: res.data[0] },function(){wx.hideLoading()});wx.setNavigationBarTitle({ title: res.data[0].title });})}
