Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
258 views
in Technique[技术] by (71.8m points)

android - 卡体中的表单在NativeBase中不可见(Form in card body not visible with NativeBase)

I try using below code (a Form inside a Card component)

(我尝试使用以下代码( Card组件内的Form ))

<Card>
   <CardItem header style={{ backgroundColor: 'lightgray' }}>
   <Right>
      <Text>This is Right align text </Text>
   </Right>
   <Badge primary>
      <Text>step 1</Text>
   </Badge>
   </CardItem>
   <CardItem>
      <Body>
         <Text style={{color: 'red'}}>{this.state.error}</Text>
         <Form style={{alignSelf: 'stretch'}}>
         <Item>
            <Label>number:</Label>
            <Input keyboardType="numeric"/>
         </Item>
         <Item>
            <Label>date:</Label>
            <Input />
         </Item>
         <Item>
            <Label>number 2:</Label>
            <Input keyboardType="numeric"/>
         </Item>
         <Item>
            <Label>date 2:</Label>
            <Input />
         </Item>
         <Button success block
            >
            <Text>submit</Text>
            <Icon name='check' size={20} color="#FFFFFF"/>
         </Button>
         </Form>
      </Body>
   </CardItem>
</Card>

But in my device Nexus 7 Tab with android 5 footer not visible.

(但是在我的设备上,带有android 5页脚的Nexus 7 Tab无法显示。)

Do you have any suggestion for find the issue and fix it?

(您是否有任何发现问题的建议并加以解决?)

I'm using NativeBase 2.0.12 and React-Native 0.42.0 .

(我正在使用NativeBase 2.0.12和React-Native 0.42.0 。)

screenshot_2017-03-22-12-00-35

I think it's maybe related to this issue: https://github.com/GeekyAnts/NativeBase/issues/668

(我认为这可能与此问题有关: https : //github.com/GeekyAnts/NativeBase/issues/668)

Try 1: I change my code a little and add style={{backgroundColor: 'red'}} for CardItem that not appear and find it on the outer card component.

(尝试1:我稍微修改一下代码,然后为未出现的CardItem添加style={{backgroundColor: 'red'}} ,并在外部卡组件上找到它。)

This is my new code:

(这是我的新代码:)

<Card>
   <CardItem header style={{ backgroundColor: 'lightgray' }}>
   <Right>
      <Text>This is Right align text </Text>
   </Right>
   <Badge primary>
      <Text>step 1</Text>
   </Badge>
   </CardItem>
   <CardItem style={{backgroundColor: 'red'}}>
   <Body>
      <Text style={{color: 'red'}}>{this.state.error}</Text>
      <Form style={{alignSelf: 'stretch'}}>
      <Item>
         <Label>number:</Label>
         <Input keyboardType="numeric"/>
      </Item>
      <Item>
         <Label>date:</Label>
         <Input />
      </Item>
      <Item>
         <Label>number 2:</Label>
         <Input keyboardType="numeric"/>
      </Item>
      <Item>
         <Label>date 2:</Label>
         <Input />
      </Item>
      <Button success block
         >
         <Text>submit</Text>
         <Icon name='check' size={20} color="#FFFFFF"/>
      </Button>
      </Form>
   </Body>
   </CardItem>
</Card>

And this is new screenshot:

(这是新的屏幕截图:) screenshot_2017-03-22-18-27-22

When I remove Form component from CardItem it's render successfully like below:

(当我从CardItem删除Form组件时,它成功呈现,如下所示:)

<Card>
   <CardItem header style={{ backgroundColor: 'lightgray' }}>
   <Right>
      <Text>This is Right align text </Text>
   </Right>
   <Badge primary>
      <Text>step 1</Text>
   </Badge>
   </CardItem>
   <CardItem style={{backgroundColor: 'red'}}>
   <Body>
      <Text style={{color: 'red'}}>{this.state.error}</Text>
   </Body>
   </CardItem>
</Card>

screenshot_2017-03-22-18-32-42

Why we can't use Form inside CardItem ?

(为什么我们不能在CardItem使用Form ?)

Is it an undocumented limitation of Card component?

(Card组件是否有未记录的限制?)

  ask by b24 translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Your Card Component is having flex direction column property by default, change it to row so that the form can be visible to you below your first card.

(默认情况下,您的“卡片组件”具有“伸缩方向”列属性,请将其更改为“行”,以便您在第一张卡片下方可以看到该表单。)

`

(`)

<Card style={{ flexDirection: 'row' }}>
    <CardItem header style={{ backgroundColor: 'lightgray' }}>
        <Right>
            <Text>This is Right align text </Text>
        </Right>
        <Badge primary>
            <Text>step 1</Text>
        </Badge>
    </CardItem>
    <CardItem style={{ backgroundColor: 'red' }}>
        <Body>
            <Text style={{ color: 'red' }}>{this.state.error}</Text>
            <Form style={{ alignSelf: 'stretch' }}>
                <Item>
                    <Label>number:</Label>
                    <Input keyboardType="numeric" />
                </Item>
                <Item>
                    <Label>date:</Label>
                    <Input />
                </Item>
                <Item>
                    <Label>number 2:</Label>
                    <Input keyboardType="numeric" />
                </Item>
                <Item>
                    <Label>date 2:</Label>
                    <Input />
                </Item>
                <Button success block
                >
                    <Text>submit</Text>
                    <Icon name='check' size={20} color="#FFFFFF" />
                </Button>
            </Form>
        </Body>
    </CardItem>
</Card>

`

(`)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...