我尝试在“react native”中使用动态图像。但该方法出现了错误。怎么解决这个问题?
下面的代码片段工作正常。
const image = require('./path/to/home.jpg');
return (
<View>
<Image source={image}>
</View>
);
但是如果我把它改成动态字符串,
const image = require({img});
return (
<View>
<Image source={image}>
</View>
);
然后我收到一个错误。那么如何在React Native中显示动态图片。