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

自定义tabbar setData切换选中态无效 #7134

Open
SherlockHomer opened this issue Jul 22, 2020 · 6 comments
Open

自定义tabbar setData切换选中态无效 #7134

SherlockHomer opened this issue Jul 22, 2020 · 6 comments
Labels
F-react Framework - React T-weapp Target - 编译到微信小程序 V-2 Version - 2.x

Comments

@SherlockHomer
Copy link

相关平台

微信小程序

复现仓库

https://github.com/SherlockHomer/taro-2.0.5
小程序基础库: 2.10.1
使用框架: React

复现步骤

  1. git clone https://github.com/SherlockHomer/taro-2.0.5
  2. npm i
  3. npm run dev:weapp
  4. 切换tabbar

期望结果

切换tabbar,选中态正常

实际结果

切换tabbar,选中态错误

环境信息

 Taro CLI 2.0.5 environment info:
    System:
      OS: macOS 10.15.5
      Shell: 5.7.1 - /bin/zsh
    Binaries:
      Node: 10.15.3 - ~/.nvm/versions/node/v10.15.3/bin/node
      Yarn: 1.16.0 - ~/.nvm/versions/node/v10.15.3/bin/yarn
      npm: 6.4.1 - ~/.nvm/versions/node/v10.15.3/bin/npm
    npmPackages:
      @tarojs/components: 2.0.5 => 2.0.5 
      @tarojs/components-qa: 2.0.5 => 2.0.5 
      @tarojs/mini-runner: 2.0.5 => 2.0.5 
      @tarojs/router: 2.0.5 => 2.0.5 
      @tarojs/taro: 2.0.5 => 2.0.5 
      @tarojs/taro-alipay: 2.0.5 => 2.0.5 
      @tarojs/taro-h5: 2.0.5 => 2.0.5 
      @tarojs/taro-qq: 2.0.5 => 2.0.5 
      @tarojs/taro-quickapp: 2.0.5 => 2.0.5 
      @tarojs/taro-rn: 2.0.5 => 2.0.5 
      @tarojs/taro-swan: 2.0.5 => 2.0.5 
      @tarojs/taro-tt: 2.0.5 => 2.0.5 
      @tarojs/taro-weapp: 2.0.5 => 2.0.5 
      @tarojs/webpack-runner: 2.0.5 => 2.0.5 
      eslint-config-taro: 2.0.5 => 2.0.5 
      eslint-plugin-taro: 2.0.5 => 2.0.5 
      nerv-devtools: ^1.5.5 => 1.5.7 
      nervjs: ^1.5.5 => 1.5.7 
      stylelint-config-taro-rn: 2.0.5 => 2.0.5 
      stylelint-taro-rn: 2.0.5 => 2.0.5 


补充信息

微信官方demo 实践正确
https://developers.weixin.qq.com/miniprogram/dev/framework/ability/custom-tabbar.html

@taro-bot2 taro-bot2 bot added F-react Framework - React T-weapp Target - 编译到微信小程序 V-2 Version - 2.x labels Jul 22, 2020
@Iurmy
Copy link

Iurmy commented Jul 22, 2020

我记得有个api能拿到当前自定义tabbar实例,里面有tabbar.setData方法。不过自定义tabbar这一块是陈年老坑了,没点毅力填不完

@SherlockHomer
Copy link
Author

@Iurmy 我就是这么写的,但是不行,Taro3 也试过不行

this.$scope.getTabBar().setData({
      selected: 0
})

@zhaoyoushuai
Copy link

同问解决了吗

@SherlockHomer
Copy link
Author

同问解决了吗

没有,但随着微信版本升级,这个问题好像没遇到过了
我是在page.onshow后用eventCenter触发setIndex

@LuChloe
Copy link

LuChloe commented May 6, 2024

同问

@LuChloe
Copy link

LuChloe commented May 6, 2024

同问解决了吗

没有,但随着微信版本升级,这个问题好像没遇到过了 我是在page.onshow后用eventCenter触发setIndex

具体如何设置呢?还没太看懂。

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

No branches or pull requests

4 participants