Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在视图中渲染视图而不影响样式_Javascript_Reactjs_React Native - Fatal编程技术网

Javascript 如何在视图中渲染视图而不影响样式

Javascript 如何在视图中渲染视图而不影响样式,javascript,reactjs,react-native,Javascript,Reactjs,React Native,因此,我正在呈现一个视图,它将显示许多组件。当我不使用nestedContainer时,一切看起来都是正常的。每个组件按其应有的方式隔开,并正确对齐。现在,如果我使用nestedContainer样式添加视图,它将不再将周围的空格应用于HandRolledIcon和用户名组件。如何解决这个问题并确保嵌套视图中的这些组件使用我想要的样式 容器:{ 弹性:1, 为内容辩护:“周围的空间”, flexDirection:'列', 对齐项目:“居中”, }, 嵌套容器:{ 对齐项目:“居中”, 为内

因此,我正在呈现一个
视图
,它将显示许多组件。当我不使用
nestedContainer
时,一切看起来都是正常的。每个组件按其应有的方式隔开,并正确对齐。现在,如果我使用
nestedContainer
样式添加
视图
,它将不再将
周围的空格
应用于
HandRolledIcon
用户名
组件。如何解决这个问题并确保嵌套视图中的这些组件使用我想要的样式


容器:{
弹性:1,
为内容辩护:“周围的空间”,
flexDirection:'列',
对齐项目:“居中”,
},
嵌套容器:{
对齐项目:“居中”,
为内容辩护:“周围的空间”,
},
人权理事会:{
对齐项目:“居中”,
},
用户名:{
对齐项目:“居中”,
}

我实际上不知道你想要实现什么,但我觉得你必须复习一下你的flex box知识

查看这些链接,它可能会对您有所帮助

实现结果的一种方法是为嵌套容器提供flexGrow:1(flex:1在react native中的工作方式相同),这将使嵌套容器视图占据所有额外空间

nestedContainer: {
    flexGrow: 1,
    alignItems: 'center', // <--- This can be removed based on your requirements since its already given to the parent view
    justifyContent: 'space-around',
  },
nestedContainer:{
flexGrow:1,

alignItems:'center',//将flewGrow:2添加到嵌套容器中,并获得了所需的结果!关于flexbox的第一个链接很有帮助!
nestedContainer: {
    flexGrow: 1,
    alignItems: 'center', // <--- This can be removed based on your requirements since its already given to the parent view
    justifyContent: 'space-around',
  },