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

vue3下button的openType="getPhoneNumber"回调方法onGetPhoneNumber没反应 #11445

Closed
Q-J-Brilliant opened this issue Mar 14, 2022 · 13 comments
Labels
F-vue3 Framework - Vue 3 T-weapp Target - 编译到微信小程序 V-3 Version - 3.x

Comments

@Q-J-Brilliant
Copy link

相关平台

微信小程序

小程序基础库: 2.22.0
使用框架: Vue 3

复现步骤

taro版本3.4.3,微信小程序点击button弹出手机号获取授权没有进入回调方法,jsx写法可以进入

期望结果

可以进入回调方法

实际结果

没有进入

环境信息

👽 Taro v3.4.2


  Taro CLI 3.4.2 environment info:
    System:
      OS: Windows 10
    Binaries:
      Node: 16.13.0 - C:\Program Files\nodejs\node.EXE
      Yarn: 1.22.17 - C:\Users\jc\AppData\Roaming\npm\yarn.CMD
      npm: 8.1.0 - C:\Program Files\nodejs\npm.CMD
@github-actions
Copy link
Contributor

@fujiazhang
Copy link

fujiazhang commented Mar 14, 2022

我也遇到这个问题,操,最近一年没加过班,今天害得加班2个小时,排查不到原因。
taro+vue3 + getPhoneNumber 。。。。

@wenyufei2018
Copy link

遇到了同样的问题

@b2nil
Copy link
Collaborator

b2nil commented Mar 15, 2022

大概是因为这个问题:#8796
试试全部小写: <button open-type="getPhoneNumber" @getphonenumber="callback" />

@Q-J-Brilliant
Copy link
Author

@b2nil 我用jsx写法就是正确的
image

@Q-J-Brilliant
Copy link
Author

@b2nil 最开始全小写我也试过也是不行的
image

@fujiazhang
Copy link

如下,全小写,解决问题。
image
#8796

@ZakaryCode ZakaryCode added V-3 Version - 3.x F-vue3 Framework - Vue 3 T-weapp Target - 编译到微信小程序 labels Mar 15, 2022
@xiongshj
Copy link

大概是因为这个问题:#8796 试试全部小写: <button open-type="getPhoneNumber" @getphonenumber="callback" />

谢谢,解决了我的问题。

@Chen-jj
Copy link
Contributor

Chen-jj commented Mar 28, 2022

Taro 文档有注明 Vue 的事件绑定是用 @ 代替小程序事件名的 bind。也就是说 bindgetphonenumber 使用 @getphonenumber 绑定。

JSX 同样地在文档中有注明首字母大写的 onCamelcase 格式。至于为什么不是和 React JSX 一样是 onCamelCase,是 Vue 有意为之,具体细节可以参考 #8796

image

文档地址

@Chen-jj Chen-jj closed this as completed Mar 28, 2022
@cKeygn
Copy link

cKeygn commented May 13, 2022

<button open-type="getPhoneNumber" @getphonenumber="callback" />
我使用这个方法成功了

@tclxshunquan-wang
Copy link

文档坑死人啊 ,open-type不是getphonenumber。应该是getPhoneNumber

@Chen-jj
Copy link
Contributor

Chen-jj commented May 26, 2023

<button open-type="getPhoneNumber" @getphonenumber="callback" />

image

文档没错吧

@tclxshunquan-wang
Copy link

image 这里的有点问题

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-vue3 Framework - Vue 3 T-weapp Target - 编译到微信小程序 V-3 Version - 3.x
Projects
None yet
Development

No branches or pull requests

9 participants