-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
在onLaunch时如何获取到微信小程序实例(getApp())? #753
Comments
|
@Gcaufy |
问题还没解决。使用 wepy 定义 app 时 this.$wxapp 是 undefined 原生小程序在定义 App 的时候并不能通过 getApp() 来拿到实例,而是需要直接用 this 来访问到。参考:https://mp.weixin.qq.com/debug/wxadoc/dev/framework/app-service/app.html |
这个问题同样困扰了我 登陆信息放在哪里很头疼 |
希望可以尽快解决哈,不过现在我是放在storage中的@wuzhuzhu |
@Gcaufy 我也遇到了同样的问题,麻烦下个版本解决下,谢谢 |
@wuzhuzhu 自己定义个全局对象,放里面就好了 |
@ZhuoYitao 你说的定义一个全局变量如何理解? 比如我的需求是在app.wpy中实现一个功能组件 想在onLaunch中定义 onLaunch(){
this.loginSdk = new LoginSdk();
const app = getApp(); // 这也是失败的app为undefined
} 在 |
this.$parent.globalData.userInfo |
这是什么神仙操作 |
在原生的写法中,
onLaunch
中可以通过this
指针获取到小程序实例。但是wepy里直接getApp()
或者wepy.$instance.$wxapp
获得的是undefined
。这种情形下有没有方法可以直接获得小程序实例?
The text was updated successfully, but these errors were encountered: