Use with a local file

前端 未结 10 939
醉梦人生
醉梦人生 2021-02-01 01:56

The documentation says that the only way to reference a static image is to use require.

But I\'m not sure where does react expect to have those images. The examples don

10条回答
  •  無奈伤痛
    2021-02-01 02:19

    This from https://github.com/facebook/react-native/issues/282 worked for me:

    adekbadek commented on Nov 11, 2015 It should be mentioned that you don't have to put the images in Images.xcassets - you just put them in the project root and then just require('./myimage.png') as @anback wrote Look at this SO answer and the pull it references

提交回复
热议问题