this.data.messageId } else if (res.cancel) { console.log('用户点击取消') } } }) 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 如果这么写,会遇到“Cannot read property 'data' of undefined ”的错误。、 箭头函数是ES6的写法,不同的写法,会导致“this”的指代层级不同,所以会找不到data属性。
success (res) {if(res.confirm) {this.data.messageId }elseif(res.cancel) { console.log('用户点击取消') } } }) 如果这么写,会遇到“Cannot read property 'data' of undefined ”的错误。 如果改成箭头函数的写法,就不会出错。 wx.showModal({ title:'提示', content:'这是一个模态弹窗', succes...
我们只用在OntitleClick事件里面加上var that = this;就行了 因为在调用 OntitleClick() 之前就已经把 this 复制了一份保存在 that 变量中,你复制的这个this是指向的page中data,那你相当于用这行代码搭了个桥,让that.setData指向了Page中的data 2.用箭头函数一样好使 这样和上面是一样的,我在慕课上面看到有...
11. 如果这么写,会遇到“Cannot read property ‘data’ of undefined ”的错误。 如果将success改成箭头函数的写法,就不会出错。 wx.request({ url: 'http://192.168.0.108:8080/wx_background_war_exploded/Servlet04', //仅为示例,并非真实的接口地址 data: { }, header: { 'content-type': '...
简介:【微信小程序】TypeError: Cannot read property ‘get‘ of undefined & Error: MiniProgramError 一、问题场景 在写 uni-app 项目的时候,跟着视频一步一步的弄,一运行就发现报错了,然后就开始各种百度了。 找不到定义 WAServiceMainContext.js?t=wechat&s=1680006165208&v=2.30.2:1 TypeError: Can...
解决办法:loginAct: () => {}改成loginAct(){} loginAct(){console.log("执行了");varthat=this;wx.getStorage({key:'user',success:function(res){console.log("信息数据res为",res);that.setData({userInfo:res.data,},()=>{console.log("重新刷新数据");})}})}...
微信小程序报Cannot read property ‘forceUpdate’ of undefined错误? 1.更改微信开发者工具appId 2.HBulder保存appId 3.最后重启项目
打开之后找到微信小程序配置——> 微信小程序AppID 把你自己的小程序ID填进去之后重启HBuilder 和微信开发者工具,然后重新运行当前项目就OK了
Cannot read property 'type' of undefined;系统找不到你以为的对象里的某个属性 从at api request success callback function来看,你需要检查回调函数里给你的result结果是否存在,并且是否有该属性
然后把this输一下是undefined,因为这个时候this指向的是当前wx对象,而wx对象没有setData,我们应该将this的指向修改为page对象 只要把success改成箭头函数就ok啦。。。