【发布时间】:2018-01-24 16:24:04
【问题描述】:
我的代码是这样的---
import React from 'react';
import {View,Text,Alert,StyleSheet} from 'react-native';
const data = ['All','Electronics','Baby and Child','Property'];
const styles=StyleSheet.create({
itemStyles: {
color: "#F456A3",
fontSize:30,
fontWeight:"bold",
},
CategoryStyle: {
flex:1,
justifyContent:'center',
flexDirection:'row'
}
});
export default class FilterScreen extends React.Component {
constructor(){
super();
this.test;
}
renderCategories = () =>{
//Alert.alert(data[0]);
this.test=data.map(item => {
return(
<View key={item} style={styles.CategoryStyle}>
<Text style={styles.itemStyles}>{item}</Text>
</View>
)
})
return this.test;
}
render(){
return(
<View>
<Text>hello world</Text>
{this.renderCategories()}
</View>
)
}
}
我必须将样式应用于呈现类别中的文本,以便它应该连续包含 2 个文本。所以,这里将有 2 行 2 文本。
如何做到这一点?
【问题讨论】:
标签: css reactjs react-native flexbox react-native-android