javascript - react native : Image doesn't show in the view

标签 javascript image typescript react-native components

抱歉,如果我重新发布问题,但我找不到可以解释这一点的问题。

我的 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/

相关文章:

angular - Electron Angular2(angular-cli)要求内部模块失败

java - struts 到 javascript 的字符串变量

php - jQuery-File-Upload 仅用于 UI?

javascript - 带有标志的 Html 国家/地区列表

javascript - 夜巡通天塔 7 设置 : Unexpected identifier

jQuery + Fluid Images Chrome Bug

java - 使用Java将图像上传到MySql数据库

image - 如何将背景图像淡化为透明?

仅具有使用特定模板参数值定义的属性的 TypeScript 通用接口(interface)

javascript - API 调用时的 Angular 定位控制台错误