Image React-native 不起作用 [英] Image React-native not working
本文介绍了Image React-native 不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试这样做:
但返回此错误:未知命名模块"
解决方案
我也遇到过这个问题,不能像
一样调用imagesource={require(`./img/${params.image}.png`)}
你必须使用另一个变量来存储路径然后调用它(包括require
)
例如:
let imagePath = require("../../assets/list.png");
另请注意,您不能将变量调用到 require 中.>
检查这个参考.网址:https://github.com/facebook/react-native/issues/2481
Iam trying to do this:
<Image
style={styles.image}
source={require(`./img/${params.image}.png`)}
/>
but returns me this error: "Unknown named module"
解决方案
I have also faced this issue, you can not call image like
source={require(`./img/${params.image}.png`)}
you have to use another variable to store path and then call it (including require
)
For example:
let imagePath = require("../../assets/list.png");
Also note that you can not call variable into require.
check this ref. url: https://github.com/facebook/react-native/issues/2481
这篇关于Image React-native 不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文