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

Taro的Picker组件设置disabled属性不会动态改变 #6162

Closed
wei-zone opened this issue Apr 29, 2020 · 5 comments
Closed

Taro的Picker组件设置disabled属性不会动态改变 #6162

wei-zone opened this issue Apr 29, 2020 · 5 comments
Assignees
Labels
question Further information is requested

Comments

@wei-zone
Copy link

#6087

问题描述

  • 环境:在微信小程序端
  • 问题:使用了Taro的Picker组件,动态的设置disabled属性,并不会发生变化
  • 对比:使用小程序原生的picker组件设置disabled是可以生效的

复现步骤

  1. 默认area没有数据,disabled为true
  2. 动态的改变area数据不为空
  3. 此时disabled应该为false
  4. 但是Picker还是不能点击
import {View, Picker} from '@tarojs/components'

class StoreManage extends Component {
   constructor(props) {
        super(props);
        this.state = {
            area: [
                {
                   areaName: '杭州'
               },{
                areaName: '上海'
                }
            ]
        }
}
render() {
      const {area} = this.state;
      return (
           <Picker mode='selector'
                          disabled={area.length === 0}
                          range={area} range-key='areaName'
                        >        
        </Picker>
    )
 }
}
export default StoreManage

但如果我使用这种方式,又是可以的

// 先去获取disabled的值

render() {
      const {area} = this.state;
      const disabled = area.length === 0// 先去获取disabled的值
      return (
           <Picker mode='selector'
                          disabled={disabled}
                          range={area} range-key='areaName'
                        >        
        </Picker>
    )
 }
}

期望行为

希望动态的添加disabled属性可以生效;

报错信息

没有报错,但就是没效果

系统信息

👽 Taro v2.1.3

Taro CLI 2.1.3 environment info:
System:
OS: macOS 10.15.4
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 12.13.0 - /usr/local/bin/node
Yarn: 1.21.1 - /usr/local/bin/yarn
npm: 6.12.0 - /usr/local/bin/npm
npmPackages:
@tarojs/components: 2.1.3 => 2.1.3
@tarojs/components-qa: 2.1.3 => 2.1.3
@tarojs/mini-runner: 2.1.3 => 2.1.3
@tarojs/redux: 2.1.3 => 2.1.3
@tarojs/redux-h5: 2.1.3 => 2.1.3
@tarojs/router: 2.1.3 => 2.1.3
@tarojs/taro: 2.1.3 => 2.1.3
@tarojs/taro-alipay: 2.1.3 => 2.1.3
@tarojs/taro-h5: 2.1.3 => 2.1.3
@tarojs/taro-qq: 2.1.3 => 2.1.3
@tarojs/taro-quickapp: 2.1.3 => 2.1.3
@tarojs/taro-swan: 2.1.3 => 2.1.3
@tarojs/taro-tt: 2.1.3 => 2.1.3
@tarojs/taro-weapp: 2.1.3 => 2.1.3
@tarojs/webpack-runner: 2.1.3 => 2.1.3
eslint-config-taro: 2.1.3 => 2.1.3
eslint-plugin-taro: 2.1.3 => 2.1.3
nerv-devtools: ^1.5.5 => 1.5.6
nervjs: ^1.5.5 => 1.5.6
stylelint-config-taro-rn: 2.1.3 => 2.1.3
stylelint-taro-rn: 2.1.3 => 2.1.3
taro-ui: ^2.3.3 => 2.3.3

补充信息

没有报错,但就是没效果

@taro-bot
Copy link

taro-bot bot commented Apr 29, 2020

CC @Chen-jj

@taro-bot
Copy link

taro-bot bot commented Apr 29, 2020

欢迎提交 Issue~

如果你提交的是 bug 报告,请务必遵循 Issue 模板的规范,尽量用简洁的语言描述你的问题,最好能提供一个稳定简单的复现。🙏🙏🙏

如果你的信息提供过于模糊或不足,或者已经其他 issue 已经存在相关内容,你的 issue 有可能会被关闭。

Good luck and happy coding~

@Chen-jj
Copy link
Contributor

Chen-jj commented Apr 29, 2020

@wforguo 微信的锅,length 在按路径 setData 时不会更新。所以不能直接用 length 做判断,用你的写法 2 绕过咯。

image

http://taro-docs-in.jd.com/taro/docs/debug.html#%E6%B2%A1%E6%9C%89%E4%BB%BB%E4%BD%95%E6%8A%A5%E9%94%99%EF%BC%8C%E4%BD%86%E6%98%BE%E7%A4%BA%E7%9A%84%E7%BB%93%E6%9E%9C%E4%B8%8D%E5%A6%82%E9%A2%84%E6%9C%9F

@Chen-jj Chen-jj added answered question Further information is requested labels Apr 29, 2020
@taro-bot
Copy link

taro-bot bot commented Apr 29, 2020

Hello~

您的问题楼上已经有了确切的回答,如果没有更多的问题这个 issue 将在 15 天后被自动关闭。

如果您在这 15 天中更新更多信息自动关闭的流程会自动取消,如有其他问题也可以发起新的 Issue。

Good luck and happy coding~

@wei-zone
Copy link
Author

wei-zone commented May 1, 2020

好的,了解,感谢

@wei-zone wei-zone closed this as completed May 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants