taro onChooseAvatar回调不生效

w3nuxt5m  于 9个月前  发布在  其他
关注(0)|答案(8)|浏览(94)

相关平台

微信小程序

小程序基础库: 2.27.1
使用框架: React

复现步骤

<Button
open-type="chooseAvatar"
className="avatorBtn"
onChooseAvatar={(e) => {
console.log(e, '-wwwwwe')
this.chooseAvatar(e)
}}
plain={true}

期望结果

微信关闭getUserInfo功能后 使用taro的Button组件openType=chooseAvatar时点击后onChooseAvatar无回调

实际结果

希望点击后有回调并且拿到微信头像

环境信息

  1. Taro CLI 3.2.8 environment info:
  2. System:
  3. OS: Windows 10
  4. Binaries:
  5. Node: 12.22.6 - C:\Program Files\nodejs\node.EXE
  6. npm: 6.14.15 - C:\Program Files\nodejs\npm.CMD
atmip9wb

atmip9wb1#

你的taro版本不够,至少需要升级到3.4.3

y1aodyip

y1aodyip2#

onChooseAvatar 返回的类型为 any ,是否有计划补全类型

bxjv4tth

bxjv4tth3#

如果是taro3.x版本,可以采用打补丁,具体细节参考这篇博客 https://blog.wmfree.top/2022/09/26/Taro3.x%E6%94%AF%E6%8C%81%E8%8E%B7%E5%8F%96%E5%A4%B4%E5%83%8F/

6za6bjd0

6za6bjd04#

同样问题 我taro版本是3.6.2,但是获取不到微信头像

  1. <template>
  2. <view class="index">
  3. <button class="avatar-wrapper" open-type="chooseAvatar" onChooseAvatar="onChooseAvatar">
  4. <img class="avatar" src="{{avatarUrl}}" />
  5. </button>
  6. <input type="nickname" class="weui-input" placeholder="请输入昵称" v-model="nickName" />
  7. </view>
  8. </template>
  9. <script>
  10. import { reactive, toRefs } from 'vue';
  11. export default {
  12. setup() {
  13. const state = reactive({
  14. visible: true,
  15. avatarUrl: "https://img12.360buyimg.com/imagetools/jfs/t1/143702/31/16654/116794/5fc6f541Edebf8a57/4138097748889987.png",
  16. nickName: "test",
  17. })
  18. const onChooseAvatar = (e) => {
  19. const { avatarUrl } = e.detail
  20. console.log("===== avatarUrl", avatarUrl)
  21. state.avatarUrl = avatarUrl
  22. }
  23. return {
  24. ...toRefs(state),
  25. onChooseAvatar
  26. }
  27. },
  28. }
  29. </script>

依赖库:

  1. 👽 Taro v3.6.2
  2. Taro CLI 3.6.2 environment info:
  3. System:
  4. OS: macOS 11.7
  5. Shell: 5.8 - /bin/zsh
  6. Binaries:
  7. Node: 16.19.1 - /usr/local/bin/node
  8. Yarn: 1.22.19 - /usr/local/bin/yarn
  9. npm: 8.19.3 - /usr/local/bin/npm
  10. npmPackages:
  11. @tarojs/cli: 3.6.2 => 3.6.2
  12. @tarojs/components: 3.6.2 => 3.6.2
  13. @tarojs/helper: 3.6.2 => 3.6.2
  14. @tarojs/plugin-framework-vue3: 3.6.2 => 3.6.2
  15. @tarojs/plugin-html: 3.6.2 => 3.6.2
  16. @tarojs/plugin-platform-alipay: 3.6.2 => 3.6.2
  17. @tarojs/plugin-platform-h5: 3.6.2 => 3.6.2
  18. @tarojs/plugin-platform-jd: 3.6.2 => 3.6.2
  19. @tarojs/plugin-platform-qq: 3.6.2 => 3.6.2
  20. @tarojs/plugin-platform-swan: 3.6.2 => 3.6.2
  21. @tarojs/plugin-platform-tt: 3.6.2 => 3.6.2
  22. @tarojs/plugin-platform-weapp: 3.6.2 => 3.6.2
  23. @tarojs/runtime: 3.6.2 => 3.6.2
  24. @tarojs/shared: 3.6.2 => 3.6.2
  25. @tarojs/taro: 3.6.2 => 3.6.2
  26. @tarojs/webpack5-runner: 3.6.2 => 3.6.2
  27. babel-preset-taro: 3.6.2 => 3.6.2
  28. eslint-config-taro: 3.6.2 => 3.6.2
展开查看全部
vvppvyoh

vvppvyoh5#

同样问题 我taro版本是3.6.2,但是获取不到微信头像

  1. <template>
  2. <view class="index">
  3. <button class="avatar-wrapper" open-type="chooseAvatar" onChooseAvatar="onChooseAvatar">
  4. <img class="avatar" src="{{avatarUrl}}" />
  5. </button>
  6. <input type="nickname" class="weui-input" placeholder="请输入昵称" v-model="nickName" />
  7. </view>
  8. </template>
  9. <script>
  10. import { reactive, toRefs } from 'vue';
  11. export default {
  12. setup() {
  13. const state = reactive({
  14. visible: true,
  15. avatarUrl: "https://img12.360buyimg.com/imagetools/jfs/t1/143702/31/16654/116794/5fc6f541Edebf8a57/4138097748889987.png",
  16. nickName: "test",
  17. })
  18. const onChooseAvatar = (e) => {
  19. const { avatarUrl } = e.detail
  20. console.log("===== avatarUrl", avatarUrl)
  21. state.avatarUrl = avatarUrl
  22. }
  23. return {
  24. ...toRefs(state),
  25. onChooseAvatar
  26. }
  27. },
  28. }
  29. </script>

依赖库:

  1. 👽 Taro v3.6.2
  2. Taro CLI 3.6.2 environment info:
  3. System:
  4. OS: macOS 11.7
  5. Shell: 5.8 - /bin/zsh
  6. Binaries:
  7. Node: 16.19.1 - /usr/local/bin/node
  8. Yarn: 1.22.19 - /usr/local/bin/yarn
  9. npm: 8.19.3 - /usr/local/bin/npm
  10. npmPackages:
  11. @tarojs/cli: 3.6.2 => 3.6.2
  12. @tarojs/components: 3.6.2 => 3.6.2
  13. @tarojs/helper: 3.6.2 => 3.6.2
  14. @tarojs/plugin-framework-vue3: 3.6.2 => 3.6.2
  15. @tarojs/plugin-html: 3.6.2 => 3.6.2
  16. @tarojs/plugin-platform-alipay: 3.6.2 => 3.6.2
  17. @tarojs/plugin-platform-h5: 3.6.2 => 3.6.2
  18. @tarojs/plugin-platform-jd: 3.6.2 => 3.6.2
  19. @tarojs/plugin-platform-qq: 3.6.2 => 3.6.2
  20. @tarojs/plugin-platform-swan: 3.6.2 => 3.6.2
  21. @tarojs/plugin-platform-tt: 3.6.2 => 3.6.2
  22. @tarojs/plugin-platform-weapp: 3.6.2 => 3.6.2
  23. @tarojs/runtime: 3.6.2 => 3.6.2
  24. @tarojs/shared: 3.6.2 => 3.6.2
  25. @tarojs/taro: 3.6.2 => 3.6.2
  26. @tarojs/webpack5-runner: 3.6.2 => 3.6.2
  27. babel-preset-taro: 3.6.2 => 3.6.2
  28. eslint-config-taro: 3.6.2 => 3.6.2

我的3.6.6也是,有解决的方法吗?

展开查看全部
rnmwe5a2

rnmwe5a26#

啥时候回收的,没看到消息呀,有微信的通知link么

ui7jx7zq

ui7jx7zq7#

啥时候回收的,没看到消息呀,有微信的通知link么
https://developers.weixin.qq.com/community/develop/doc/00022c683e8a80b29bed2142b56c01

自 2022 年 10 月 25 日 24 时后(以下统称 “生效期” ),用户头像昵称获取规则将进行如下调整:

自生效期起,小程序 wx.getUserProfile 接口将被收回:生效期后发布的小程序新版本,通过 wx.getUserProfile 接口获取用户头像将统一返回默认 灰色头像 ,昵称将统一返回 “微信用户”。生效期前发布的小程序版本不受影响,但如果要进行版本更新则需要进行适配。
自生效期起,插件通过 wx.getUserInfo 接口获取用户昵称头像将被收回:生效期后发布的插件新版本,通过 wx.getUserInfo 接口获取用户头像将统一返回默认 灰色头像 ,昵称将统一返回 “微信用户”。生效期前发布的插件版本不受影响,但如果要进行版本更新则需要进行适配。通过 wx.login 与 wx.getUserInfo 接口获取 openId、unionId 能力不受影响。

juzqafwq

juzqafwq8#

同样问题 我taro版本是3.6.2,但是获取不到微信头像

  1. <template>
  2. <view class="index">
  3. <button class="avatar-wrapper" open-type="chooseAvatar" onChooseAvatar="onChooseAvatar">
  4. <img class="avatar" src="{{avatarUrl}}" />
  5. </button>
  6. <input type="nickname" class="weui-input" placeholder="请输入昵称" v-model="nickName" />
  7. </view>
  8. </template>
  9. <script>
  10. import { reactive, toRefs } from 'vue';
  11. export default {
  12. setup() {
  13. const state = reactive({
  14. visible: true,
  15. avatarUrl: "https://img12.360buyimg.com/imagetools/jfs/t1/143702/31/16654/116794/5fc6f541Edebf8a57/4138097748889987.png",
  16. nickName: "test",
  17. })
  18. const onChooseAvatar = (e) => {
  19. const { avatarUrl } = e.detail
  20. console.log("===== avatarUrl", avatarUrl)
  21. state.avatarUrl = avatarUrl
  22. }
  23. return {
  24. ...toRefs(state),
  25. onChooseAvatar
  26. }
  27. },
  28. }
  29. </script>


依赖库: ``` 👽 Taro v3.6.2

Taro CLI 3.6.2 environment info:
System:
OS: macOS 11.7
Shell: 5.8 - /bin/zsh
Binaries:
Node: 16.19.1 - /usr/local/bin/node
Yarn: 1.22.19 - /usr/local/bin/yarn
npm: 8.19.3 - /usr/local/bin/npm
npmPackages:
@tarojs/cli: 3.6.2 => 3.6.2
@tarojs/components: 3.6.2 => 3.6.2
@tarojs/helper: 3.6.2 => 3.6.2
@tarojs/plugin-framework-vue3: 3.6.2 => 3.6.2
@tarojs/plugin-html: 3.6.2 => 3.6.2
@tarojs/plugin-platform-alipay: 3.6.2 => 3.6.2
@tarojs/plugin-platform-h5: 3.6.2 => 3.6.2
@tarojs/plugin-platform-jd: 3.6.2 => 3.6.2
@tarojs/plugin-platform-qq: 3.6.2 => 3.6.2
@tarojs/plugin-platform-swan: 3.6.2 => 3.6.2
@tarojs/plugin-platform-tt: 3.6.2 => 3.6.2
@tarojs/plugin-platform-weapp: 3.6.2 => 3.6.2
@tarojs/runtime: 3.6.2 => 3.6.2
@tarojs/shared: 3.6.2 => 3.6.2
@tarojs/taro: 3.6.2 => 3.6.2
@tarojs/webpack5-runner: 3.6.2 => 3.6.2
babel-preset-taro: 3.6.2 => 3.6.2
eslint-config-taro: 3.6.2 => 3.6.2

我的3.6.6也是,有解决的方法吗?
你写错了。 vue的写法是和小程序一致。不能带on. on是react才有的。 这样写就没问题了
<button open-type="chooseAvatar" @chooseAvatar="onChooseAvatar" size="mini" class="btn-avatar">

展开查看全部

相关问题