【发布时间】:2017-12-07 17:19:26
【问题描述】:
这是我想让请关注产品的观点,这就是我所做的:
我制作了一个名为“AllProducts”的组件并将其放在flexDirection 到row 并在其上绑定我的产品数组,但我得到了这个结果
如果有帮助,这是我的代码:
这是我的 AllProduct.js
const Product_kind_one = [{
name : 'Nice cloth',
price : '2,999',
image : require('../imgs/1.jpg')
},{
name : 'Orange cloth',
price : '3,999',
image : require('../imgs/2.jpg')
},{
name : 'Pink cloth',
price : '2,999',
image : require('../imgs/3.jpg')
},{
name : 'Colory cloth',
price : '1,999',
image : require('../imgs/4.jpg')
},{
name : 'Dark High Heels',
price : '0,999',
image : require('../imgs/5.jpeg')
},{
name : 'Blue Nice Shoes',
price : '3,599',
image : require('../imgs/6.jpg')
},{
name : 'Women Blue Bag',
price : '2,299',
image : require('../imgs/7.png')
}];
const Product_kind_two = [{
name : 'Women Red Bag',
price : '2,299',
image : require('../imgs/9.jpg')
},{
name : 'Bow tie Shoes',
price : '1,299',
image : require('../imgs/10.jpg')
},{
name : 'Dark Black Bag',
price : '1,299',
image : require('../imgs/13.jpg')
},{
name : 'Cream Shoes',
price : '3,499',
image : require('../imgs/12.jpg')
},{
name : 'Green and Blue Shoes',
price : '5,499',
image : require('../imgs/12.jpg')
}];
export default class AllProducts extends Component{
render(){
return(
<View style={{flexDirection : 'row',justifyContent : 'center'}}>
<View style={{flex : 1,justifyContent : 'center'}}>
<Products Products={Product_kind_one}/>
</View>
<View style={{flex : 1,justifyContent : 'center'}}>
<Products Products={Product_kind_two}/>
</View>
</View>
)
}
}
这是我的 Product.js
return(
<View style={{flexDirection : 'column'}}>
{this.props.Products.map((Product,index)=>{
console.log(Product.image);
return(
<View key={index} style={{backgroundColor : '#fff',borderRadius : 5,justifyContent : 'center',margin : 10}}>
<Image source={Product.image} style={{height : 200,width : null,resizeMode : 'cover'}} />
<TouchableOpacity style={{alignItems : 'flex-end',justifyContent : 'center',position : 'absolute',top : 10,right : 10 }}>
<LikeButton/>
</TouchableOpacity>
<View style={styles.priceContainer}>
<Text style={{fontSize : 12}}>Stripped Mxi Dress</Text>
<Text style={{color : 'rgb(219, 10, 91)'}}>Rs.1,299</Text>
</View>
</View>
)
})}
</View>
)
我哪里做错了???
【问题讨论】:
-
您是否希望列中的项目具有不同的高度?还是说右上角有个洞?
-
是的,我的问题是我希望列中的项目位于不同的高度
标签: reactjs react-native flexbox react-native-android styling