在 NativeBase ui 库中使用 <Container> 和 <View> 有区别吗?
is there a difference between using <Container> and <View> in NativeBase ui library?
NativeBase 表示将所有组件包装在 <Container></Container>
标签内。
- 是否意味着替换所有
<View></View>
标签?
- 使用全部时在功能或布局上是否有任何差异?
<Container>
个标签替换所有 <View>
个标签,反之亦然?
- 我是否应该每个屏幕只使用一个
<Container>
并使用 <View>
该屏幕内的其余容器?
你问题的第三点是正确的。 Container
组件应该在每个屏幕上只使用一次来包装所有子组件,有点像 React.Fragment
.
Container
通常需要三个子组件
<Container>
<Header> //<-always on top
...
</Header>
<Content> //<-supports scrolling
...
</Content>
<Footer> //<-always in the bottom
...
</Footer>
</Container>
Are there any differences in functionality or layout when using all
tags to replace all tags and vice versa?
不建议将所有 View
替换为 Container
,因为 Container
有其默认样式,它的行为与使用 View
组件时的行为不同包装组件。
NativeBase 表示将所有组件包装在 <Container></Container>
标签内。
- 是否意味着替换所有
<View></View>
标签? - 使用全部时在功能或布局上是否有任何差异?
<Container>
个标签替换所有<View>
个标签,反之亦然? - 我是否应该每个屏幕只使用一个
<Container>
并使用<View>
该屏幕内的其余容器?
你问题的第三点是正确的。 Container
组件应该在每个屏幕上只使用一次来包装所有子组件,有点像 React.Fragment
.
Container
通常需要三个子组件
<Container>
<Header> //<-always on top
...
</Header>
<Content> //<-supports scrolling
...
</Content>
<Footer> //<-always in the bottom
...
</Footer>
</Container>
Are there any differences in functionality or layout when using all tags to replace all tags and vice versa?
不建议将所有 View
替换为 Container
,因为 Container
有其默认样式,它的行为与使用 View
组件时的行为不同包装组件。