为了账号安全,请及时绑定邮箱和手机立即绑定

如何使用 call()来改变this的指向

如何使用 call()来改变this的指向

慕容森 2019-05-08 16:15:47
写小程序的时候发现小程序内置的api里是不能使用this。于是定义了一个变量_self来保存this。想问下如果使用call()应该怎么写。第二个这么些好像不行letrpxlet_self=this//获取系统信息wx.getSystemInfo({success(res){_self.windowHeight=res.windowHeight+'px'_self.windowWidth=res.windowWidthrpx=res.windowWidth/750_self.rpx=rpx}})wx.getSystemInfo.call(this,{success(res){this.windowHeight=res.windowHeight+'px'this.windowWidth=res.windowWidthrpx=res.windowWidth/750this.rpx=rpx}})
查看完整描述

2 回答

  • 2 回答
  • 0 关注
  • 763 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信