Skip to content
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

Button组件onGetUserInfo未执行 #421

Closed
JerrySir opened this issue Aug 2, 2018 · 5 comments

Comments

@JerrySir
Copy link
Contributor

commented Aug 2, 2018

问题描述
在获取用户信息时,官方文档给出
<button open-type="getUserInfo" lang="zh_CN" bindgetuserinfo="onGotUserInfo">获取用户信息</button> ...... onGotUserInfo: function(e) { console.log(e.detail.errMsg) console.log(e.detail.userInfo) console.log(e.detail.rawData) }

转成Taro框架下:
<button open-type="getUserInfo" lang="zh_CN" onGetUserInfo={this.onGotUserInfo}>获取用户信息</button> ...... onGotUserInfo (e) { console.log(e.detail.errMsg) console.log(e.detail.userInfo) console.log(e.detail.rawData) }
未执行

换官方回调参数:
<button open-type="getUserInfo" lang="zh_CN" bindgetuserinfo={onGotUserInfo}>获取用户信息</button>
输出以下警告:

Do not have onGotUserInfo handler in current page: pages/index/index. Please make sure that onGotUserInfo handler has been defined in pages/index/index, or pages/index/index has been added into app.json

能想的办法都想过了,使用 bindgetuserinfo + 其他函数
<button open-type="getUserInfo" lang="zh_CN" bindgetuserinfo={showLocation}>获取用户信息</button> ...... showLocation() { console.log('oye') }
正常输出

But! 奇怪的在后面:
<button open-type="getUserInfo" lang="zh_CN" bindgetuserinfo={showLocations}>获取用户信息</button> ...... // 地图上显示当前位置 showLocations() { console.log('oye') }

又会提示:

Do not have showLocations handler in current page: pages/index/index. Please make sure that showLocations handler has been defined in pages/index/index, or pages/index/index has been added into app.json

代码截图如下
https://github.com/JerrySir/An_client/blob/master/src/pages/index/index.js#L118

@JerrySir JerrySir closed this Aug 2, 2018

@JerrySir

This comment has been minimized.

Copy link
Contributor Author

commented Aug 2, 2018

解决方法:
button改为Button
open-type改为openType

@JerrySir

This comment has been minimized.

Copy link
Contributor Author

commented Aug 8, 2018

<Button id='login-btn' openType="getUserInfo" lang="zh_CN" onGetUserInfo={onGotUserInfo} type='primary' >微信用户快速登录</Button>

@esc95

This comment has been minimized.

Copy link

commented Mar 21, 2019

解决了 谢谢

@nshen

This comment has been minimized.

Copy link

commented May 29, 2019

老哥,这段应该写到文档里啊

<Button id='login-btn' openType="getUserInfo" lang="zh_CN" onGetUserInfo={onGotUserInfo} type='primary' >微信用户快速登录</Button>

@qingo

This comment has been minimized.

Copy link

commented Jun 22, 2019

文档里确实没找到

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.