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

动态修改form-picker的disabled属性,form-picker状态不会及时更新, #1231

Closed
3 tasks
YanFanCode opened this issue Jul 2, 2024 · 1 comment
Closed
3 tasks

Comments

@YanFanCode
Copy link

组件

form-picker组件

基础库版本

  • 1.x
  • [1 ] 2.x

设备机型

手机系统

  • [1 ] iOS
  • Android
  • HarmonyOS

APP

钉钉小程序

组件库版本

2.35.1

预期行为

根据data内部的true和false,动态加载是否能点击弹出picker选择

复现步骤

  1. 绑定data内部布尔类型数据,在方法内部动态改变,页面上组件状态不更新,使用的this.setData()更新

复现 demo

xml

js: isThreeDaysAgo是一个方法 返回 true 或 false
if (isThreeDaysAgo(date)) {
this.setData({
isDelayFiling: true,
disabledInfo: true
})
} else {
this.setData({
disabledInfo: false,
isDelayFiling: false
})
}

@rayhomie
Copy link
Contributor

rayhomie commented Jul 2, 2024

image image

我这边正常的。

<view class="editorial_staff">
  <view class="editorial_scroll">
    <scroll-view scroll-y class="editorial_info">
      <form-picker
        label="水果"
        arrow
        name="fruit"
        options="{{ fruitList }}"
        ref="handleRef" 
        disabled="{{pickerDisabled}}"
        />
        pickerDisabled:{{pickerDisabled}}
    </scroll-view>
  </view>
  <view class="editorial_btn">
    <ant-button type="primary" onTap="dis">
      改变pickerDisabled
    </ant-button>
  </view>
</view>
import {
  Form
} from 'antd-mini/es/Form/form';

Page({
  data: {
    fruitList: ['苹果', '香蕉', '橘子', '西瓜'],
    pickerDisabled: false,
  },
  onLoad() {
    this.form = new Form();
  },
  handleRef(ref) {
    this.form.addItem(ref);
  },
  dis() {
    const {
      pickerDisabled
    } = this.data

    this.setData({
      pickerDisabled: !pickerDisabled
    })
  }
});

@rayhomie rayhomie closed this as completed Jul 2, 2024
@rayhomie rayhomie reopened this Jul 2, 2024
@rayhomie rayhomie closed this as completed Jul 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants