react-native - Nativebase - 单击输入时如何显示日期选择器?

标签 react-native native-base

我正在使用NativeBase组件。我有带有以下字段的 Form:

       <Item floatingLabel last>
          <Label>Buy dateі</Label>
          <DatePicker
            defaultDate={buyTime}
            locale={"en"}
            modalTransparent={false}
            animationType={"fade"}
            androidMode={"default"}
            placeHolderText="Change buy date"
            textStyle={{ color: "green" }}
            placeHolderTextStyle={{ color: "#d3d3d3" }}
            onDateChange={this.handleBuyTimeChange}
            disabled={false}
            ref={component => (this.buyTimePicker = component)}
          />
          <Input
            value={buyTime.toString().substr(4, 12)}
            onPress={() => {
              this.buyTimePicker.showDatePicker();
            }}
          />
        </Item>

但是点击Input不会触发DatePicker。如何解决这个问题?

最佳答案

您无法使用自己的输入组件自定义 native 日期选择器,如果您坚持这样做,您可以使用任何第 3 方库,例如:https://www.npmjs.com/package/react-native-modal-datetime-picker .

关于react-native - Nativebase - 单击输入时如何显示日期选择器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54047385/

相关文章:

react-native - 捕获 Ref 或自定义从 JSX/HTML 生成图像 react native 而不向用户显示 UI

javascript - react native : Is it is good to use UI kit for design purpose?

javascript - 表单中的默认值

react-native - react native : How to inline a textInput with a button?

react-native - 样式中带有边距的 Native Base 按钮​​并不包含其中的文本

react-native - 使用 Native Base Toast 显示来自 Redux 操作的错误

react-native - 如何解决 React Native 中的此错误

ios - didReceiveLocalNotification、didReceiveRemoteNotification 和 willPresentNotification 从未在通知出现时触发,React Native App

react-native - 使用 react-native-testing-library 在 Jest 中未呈现 NativeBase 内容

javascript - 将值从一种模式传递到另一种模式