js文件:
Page({
/**
-
页面的初始数据
*/
data: {},
/**
-
生命周期函数--监听页面加载
*/
onLoad: function (options) {},
/**
-
生命周期函数--监听页面初次渲染完成
*/
onReady: function () {},
/**
-
生命周期函数--监听页面显示
*/
onShow: function () {},
/**
-
生命周期函数--监听页面隐藏
*/
onHide: function () {},
/**
-
生命周期函数--监听页面卸载
*/
onUnload: function () {},
/**
-
页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {},
/**
-
页面上拉触底事件的处理函数
*/
onReachBottom: function () {},
/**
-
用户点击右上角分享
*/
onShareAppMessage: function () {},
insert: function () {
wx.cloud.init({
evn: "wx811b764f625803cd"
});
let db = wx.cloud.database();
let test = db.collection("test");
test.add({
data: {
name: "gggg",
age: "18"},
success: function () {
console.log("插入成功");
},
fail: function (error) {
console.log(error);},
complete: function () {
console.log("完成");
}
});
}
})
wxml文件:
<button bindtap="insert">插入一组数据</button>
错误情况:
Error: errCode: -501005 invalid env | errMsg: Environment not found
at new t (WAService.js:22)
at Function.success (WAService.js:20)
at Object.success (WAService.js:4)
at s (WAService.js:6)
at WAService.js:6
at n. (appservice?t=1563778321226:1407)
at WAService.js:4
at WAService.js:4
shujiku.js:86 完成