使用时:
<Image source={require('./img/name.png')} />
效果很好,但我如何使用变量?
<Image source={require('./img/'+rowData.imageFile+'.png')} />
文档显示了此示例https://facebook.github.io/react-native/docs/images.html
// GOOD
var icon = this.props.active ? require('./my-icon-active.png') : require('./my-icon-inactive.png');
<Image source={icon} />
但这并不能解决我的问题。
答案 0 :(得分:0)
这有效:https://facebook.github.io/react-native/docs/images.html#images-from-hybrid-app-s-resources
public class SubsystemFacade {
public String method1() throws CustomException {
//do something
}
public String method2() throws CustomException {
//do something
}
private String exceptionHandlerForThisClass(CustomException e) {
//do something with the exception
}
}
只需将图像放在/ android / app / src / main / res / drawable /下,并手动指定图像尺寸。