【发布时间】:2018-01-03 19:54:44
【问题描述】:
我正在使用模拟数据构建一个反应原生应用程序。我能够在平面列表中呈现一些模拟数据,但图像不会呈现。在 react native devtools 中,它显示了图像 url,但没有显示任何样式,即使我在 Stylesheet 元素中有样式。
import React, { Component } from "react";
import { StyleSheet, Text, View, Image, ListView } from "react-native";
class BookItem extends Component {
render(){
return (
<View style = {styles.bookItem}>
<Image style = {styles.cover} /> //is this the issue?
<View style = {styles.info}>
<Text style = {styles.author}>{this.props.author}</Text>
<Text style = {styles.title}>{this.props.title}</Text>
</View>
</View>
);
}
}
const styles = StyleSheet.create({
bookItem: {
flexDirection: "row",
backgroundColor: "#FFFFFF",
borderBottomColor: "#AAAAAA",
borderBottomWidth: 2,
padding: 5,
height: 175
},
cover: {
flex: 1,
height: 150,
resizeMode: "contain"
},
info: {
flex: 3,
alignItems: "flex-end",
flexDirection: "column",
alignSelf: "center",
padding: 20
},
author: { fontSize: 18 },
title: {fontSize: 18, fontWeight: "bold"}
});
export default BookItem
我不确定我是否在本机反应中正确使用了 Image 元素。这可能是问题所在。在大多数情况下,它会在 devtools 中显示数据
【问题讨论】:
标签: javascript android css react-native