抱歉,如果我重新发布问题,但我找不到可以解释这一点的问题。
我的 render() 函数在我的 React Native 应用程序中返回此值。
<View style={styles.login_card_view}>
<Text>aaa</Text>
<Image source={require('./logo_full.png')} style={{width: 200, height: 40}}/>
<Text>bbb</Text>
<Card>
...
</Card>
<Button containerStyle={{ marginTop: 20, alignItems: 'center', flex: 1}} />
</View>
这只会导致图像出现空白区域。 (图像与我的类组件位于同一位置。)图像没有显示在该空间中,但我的两个文本“aaa”和“bbb”有 40 的差异。(这是图像的给定高度。)
我使用图像组件是否错误?这与文档完全相似。任何帮助表示赞赏!谢谢。
最佳答案
import {View,StyleSheet, Text , Button , Image} from 'react-native';
import React , {Component} from 'react';
export default class BasicExample extends React.Component{
render (){
return (
<View>
<Text>aaa</Text>
<Image source={require('./logo_full.png')} style={{width: 200, height: 40}}/>
<Text>bbb</Text>
</View>
)
}
}
我运行了这段代码,它对我有用。请记住正确输入图像位置和名称。您的代码可能有错误,例如按钮没有 标题。
关于javascript - react native : Image doesn't show in the view,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52135014/