Ant-design-mobile: Picker doesn't pop up from bottom when used in React Native

Created on 6 Feb 2017  ·  5Comments  ·  Source: ant-design/ant-design-mobile

本地环境

  • antd-mobile 版本:0.9.14
  • 浏览器 (或标明是 react-native) 及其版本:react-native
  • 运行环境及其版本:ios

你做了什么?

I first defined an array of data:

const testData = [
    {value: 1, label: '1'},
    {value: 2, label: '2'},
    {value: 3, label: '3'},
]; 

Then I included the Picker component in the render method:

<Picker
    data={testData}
    values={[1]}
    cols={1}>
    <List.Item arrow="horizontal">Option</List.Item>
</Picker>

你期待的结果是:

The Picker would pop up from the bottom of the screen when I press the 'Option' field.

实际上的结果:

The Picker didn't show up. Actually, nothing happened, not even a warning.

Interestingly, though, when I put the DatePicker component in the render method simply like this:

<DatePicker>
    <List.Item>Pick a Date</List.Item>
</DatePicker>

The DatePicker did pop up from the bottom when pressed.

Not sure if I used the component correctly.

可重现的在线演示

react native

Most helpful comment

@subject17 add prop triggerType="onClick"

<Picker data={testData} values={[1]} cols={1} triggerType="onClick">
     <List.Item arrow="horizontal">Option</List.Item>
</Picker>

All 5 comments

@subject17 add prop triggerType="onClick"

<Picker data={testData} values={[1]} cols={1} triggerType="onClick">
     <List.Item arrow="horizontal">Option</List.Item>
</Picker>

@warmhug picker 文档没有描述 triggerType,这个内置到 Piker 里?

@warmhug 建议内置进去,新手比较容易踩坑

已经内置

我踩到这个坑了

Was this page helpful?
0 / 5 - 0 ratings