react-native - 为什么容器样式不适用于 React Native 中的 View 组件
问题描述
我正在开发一个 React 项目,在该项目中,为什么容器样式不适用于 react native 中的 View Component。
这是 App.js
import React from 'react';
import {View, Text, StyleSheet} from 'react-native';
const App = () => {
return (
<View style={([styles.container], {flex: 1}, {flexDirection: 'column'})}>
<View style={{width: 50, height: 50, backgroundColor: 'powderblue'}} />
<View style={{width: 50, height: 50, backgroundColor: 'skyblue'}} />
<View style={{width: 50, height: 50, backgroundColor: 'steelblue'}} />
</View>
);
};
const styles = StyleSheet.create({
container: {
padding: 10,
marginTop: 10,
},
});
export default App;
解决方案
我认为您应该将视图容器样式编辑为此
style={[styles.container, {flex: 1, flexDirection: 'column'}]}
希望有帮助。
推荐阅读
- android - 如何修复以下代码?
- javascript - 使用javascript将行号添加到文本区域
- mysql - 从查询中导出数据并更新表(如果已存在)
- google-maps - GoogleMaps 中某个区域的 KML 文件
- javascript - Postcss-simple-vars 无法正常工作
- algorithm - 最坏情况快速排序的主定理
- discord.js - 锁定命令,使用 guild.roles 指定
- sql - 如何编写以下 SQL 查询来查找带有所需标签的内容?
- javascript - Discord.js V12 消息收集器“错误”?
- xamarin.ios - 我收到 Apple 分发配置文件的“无效代码签名权利”警告