这是微信小程序·云数据库开发的demo,其中包含三个页面:
借助于提供的云数据库,可以实现非API方式来动态加载内容。后续只需要直接云端数据库的数据,就能动态查看不同的课程以及课件。
/**
* 获取课程信息
*/
getCourses: function () {
wx.cloud.database().collection("course")
.skip(this.biz_data.page_index * CONFIG.PAGE_SIZE)
.limit(CONFIG.PAGE_SIZE)
.get()
.then(res => {
this.biz_data.loading_more = false;
if (res.data.length < CONFIG.PAGE_SIZE) {
this.data.footer.no_more = true;
} else {
this.data.footer.need_footer = true;
}
if (res.data.length == 0) {
// 空数组说明无需刷新列表内容,只需刷新footer
this.setData({
footer: {
need_footer: this.data.footer.need_footer,
no_more: this.data.footer.no_more,
}
});
} else {
this.setData({
courses: this.data.courses.concat(res.data),
footer: {
need_footer: this.data.footer.need_footer,
no_more: this.data.footer.no_more
}
})
}
})
.catch(err => {
console.error(err)
});
}
-
更换config.js里云环境的值为你自己的
function getCloudEnv () { if (getEnv() == "pro") { return "pro-xxx"; } else { return "pro-yyy"; } }
-
如果遇到以下报错信息,请将基础库调整为2.3.0及以上版本
-401002 api parameter error | errMsg: parameter offset of function skip must be provided