Problem when use dynamic value with image component react native

前端 未结 2 909
情话喂你
情话喂你 2021-01-26 18:21

I get data from DB and put it into source image, it will be error, but if i put only string it will run ok

Run ok:

相关标签:
2条回答
  • 2021-01-26 19:14

    You need to require the source in the array so that React Native can display your images dynamically. In carOfPerson array requires the link to the images

    instead of ['img1', 'img2'], you will have [require('img1'), require('img2')]

    0 讨论(0)
  • 2021-01-26 19:19

    React Native at the moment doesn't support dynamic require calls, i.e. you have to pass a complete constant string inside your require statement for it to work.

    See this github issue for more details: https://github.com/facebook/react-native/issues/6391

    0 讨论(0)
提交回复
热议问题