- 在app.js中其他函数能给globalData中的tt赋值吗?
//app.js App({ onLaunch: function () { // 展示本地存储能力 }, onShow: function (res) { console.log('test0',res.query.mm) this.globalData.tt= res.query.mm //能给globalData中的tt赋值吗? }, globalData: { userInfo: null, tt:'', } })
2020-05-15 - navigateToMiniProgram跳转成功,获取数据提示错误?
wx.navigateToMiniProgram({ appId: 'xxxxxxxxxxxxxxxxxxx', path: 'page/index/index?id=123',//---------------path为空,能跳转,但写上路径,跳转 提示:“页面不存在”????????? extraData: { //需要传递给目标小程序的数据,目标小程序可在 App.onLaunch(),App.onShow() 中获取到这份数据 test:9 }, envVersion: 'develop', //重点**要打开的小程序版本,有效值 develop(开发版),trial(体验版),release(正式版) success(res) { console.log('打开成功')// 打开成功 } 跳转成功后的页面 onShow: function (res) { console.log('test0',res.query.mm) //用query获取数据,提示出现错误:VM109:1 thirdScriptError Cannot read property 'query' of undefined;at "pages/mt/index" page lifeCycleMethod onShow function TypeError: Cannot read property 'query' of undefined at Se.onShow (http://127.0.0.1:22518/appservice/pages/mt/index.js:27:30) at Se.<anonymous> (http://127.0.0.1:22518/appservice/__dev__/WAService.js:2:1747424) at Se.p.__callPageLifeTime__ (http://127.0.0.1:22518/appservice/__dev__/WAService.js:2:1747169) at xt (http://127.0.0.1:22518/appservice/__dev__/WAService.js:2:1762938) at http://127.0.0.1:22518/appservice/__dev__/WAService.js:2:1766232 at Mt (http://127.0.0.1:22518/appservice/__dev__/WAService.js:2:1766725) at Function.<anonymous> (http://127.0.0.1:22518/appservice/__dev__/WAService.js:2:1774830) at i.<anonymous> (http://127.0.0.1:22518/appservice/__dev__/WAService.js:2:1738454) at i.emit (http://127.0.0.1:22518/appservice/__dev__/WAService.js:2:615430) at Object.emit (http://127.0.0.1:22518/appservice/__dev__/WAService.js:2:582139) },
2020-05-15 - 问题已经解决?
问题已经解决
2020-05-15 - 点击按键updata云数据库,第一条记录更新成功,再次按键,或再次运行程序点击按键,更新不成功?
const db= wx.cloud.database() Page({ onchick:function(){ var mt=19 db.collection("time").where({ //查询time云数据库 htime: mt }) .get() .then(res=>{ console.log(res); var tim=res.data[0].time; //得到 tim db.collection("timeone").add({ //写入timeone云数据库 data: { htimone:tim, htim2:0, }, success(res) { console.log("添加成功", res) }, fail(res) { console.log("添加失败", res) } }) db.collection("timeone").where({ //查询数据库 htim: (tim) }) .get() .then(res => { console.log(res); var tmid = res.data[0]._id; //查询出id var tim2=tim+1; db.collection("time").where({ //查询 bhtime:(tim2) }) .get() .then(res=>{ console.log(res); var tim3=res.data[0].time; //得到tim3 db.collection("timeone").doc(tmid).update({ //更新云数据库记录 data: { htim2:tim3 }, success: res => { console.log('成功', res.data) } }) }); }) }) } })
2020-05-14 - res返回的数据,在括号外获取不了?
res返回的数据,在括号外获取不了? onload:function(){ const db= wx.cloud.database() db.collection("time").where( xxxx: msms //查询云数据库 ) .get() .then(res=>{ console.log(res); var mmn2=res.data[0].hhtd; //hhtd为数据库中的字段 console.log("test 测试1",bh) this.setData({ mmn2: res.data[0].hhtd }) }) var wmmn2=this.data.mmn2 //获取不了mmn2,但能获取this.data???? console.log("test 测试1",wmmn2) //获取不了 wmmn2 ????? }
2020-05-13 - 1、index.js怎样传递参数到app.js中的函数tm呢?
1、app.js中的函数可以传参数到index.js, index.js怎样传递参数到app.js中的函数tm呢?求 大师指导 一、app.js中的函数传参数到index.js 1、 index.js: app.tm(function (tm) { console.log(tm) }) 2、app.js: tm: function (cb) { var dd = 'yyy' typeof cb == "function" && cb(dd) //返回输出 }, 二、index.js怎样传递参数到app.js中的函数data???????????? 1、 index.js: onload:function(){ this.setData({ mm:20 }) } 2、app.js: data: function () { console.log(this.data.mm) },
2020-05-13