小程序 同一个js文件,两个不同的funtion如何传递数值?
小程序 同一个JS页面,不同funtion如何传值
const app = getApp() Page({ data: { key1: '' , key2: '' , testid: '' }, bindTextAreaChange: function () { const db = wx.cloud.database({}); const cont = db.collection( 'test' ); var that = this ; db.collection( 'test' ).add({ data: { key1: '2' , key2: 'dasjjfksfksjdhkjfhkdfhj' }, success: function (res) { console.log(res) that.setData({ testid: res._id }) return testid }, }) }, queryData: function () { console.log(testid) const db = wx.cloud.database({}); const cont = db.collection( 'test' ); cont.doc( " " ).get({ success: function (res) { console.log(res.data) that.setData({ key2: res.data.key2 }) } }) } }) |
3 回复