简体   繁体   English

如何显示来自 c:/foldername/x.png 的本地文件路径示例中的图像

[英]How to show the image from the local file path example from c:/foldername/x.png

I would like to show the image from the File path example from c:/foldername/x.png.我想显示来自 c:/foldername/x.png 的文件路径示例中的图像。 When I have given file path, we are getting cross mark but it is not loading the image, anyone has any idea?当我给出文件路径时,我们得到了交叉标记,但它没有加载图像,有人知道吗? Code which I was working我正在工作的代码

<Image source={require('C:/Users/username/Pictures/66.png')}
      style={{
        width:220,
        height:220,
        borderWidth:2,
        borderColor:'#d35647',
        resizeMode:'stretch',
        margin:8
      }}
    />

If you have for example, the follow scafolding例如,如果您有以下脚手架

src
|____/assets
|_________imgs
|_____________mi-img.png
|____/components
|_________/MyImage
|_____________MyComponent.js

in MyComponent.js you must access to your image in the follow way:MyComponent.js中,您必须通过以下方式访问您的图像:

<Image source={require('../../assets/imgs/mi-img.png')}
      style={{
        width:220,
        height:220,
        borderWidth:2,
        borderColor:'#d35647',
        resizeMode:'stretch',
        margin:8
      }}
    />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM