React Native - How to load local image using the uri in Image Component?

前端 未结 3 1166
慢半拍i
慢半拍i 2021-02-06 03:34

I know we can load the local image with:


But i need to load the

3条回答
  •  爱一瞬间的悲伤
    2021-02-06 04:16

    In case you are using Expo to build your React Native application, this might help:

    1) Install expo-asset: expo install expo-asset

    2) Initialize and set your imageUri:

    import {Asset} from 'expo-asset';
    
    const imageURI = Asset.fromModule(require('../../assets/test.png')).uri;
    

    3) In my case, I needed it on a Thumbnail from NativeBase:

    
    

    Docs: https://docs.expo.io/versions/latest/sdk/asset/

提交回复
热议问题