我正在遵循React原生文档中描述的步骤
https://facebook.github.io/react-native/docs/integration-with-existing-apps.html
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mReactRootView = new ReactRootView(this);
mReactInstanceManager = ReactInstanceManager.builder()
.setApplication(getApplication())
.setBundleAssetName("index.android.bundle")
.setJSMainModuleName("index.android")
.addPackage(new MainReactPackage())
.setUseDeveloperSupport(BuildConfig.DEBUG)
.setInitialLifecycleState(LifecycleState.RESUMED)
.build();
mReactRootView.startReactApplication(mReactInstanceManager, "HelloWorld", null);
setContentView(mReactRootView);
}但是,当我尝试将组件图像与我的android资源中的图像一起使用时,它没有显示。
https://facebook.github.io/react-native/docs/images.html#images-from-hybrid-app-s-resources
有人将react原生应用程序集成到Android应用程序中,并使用资产中的图像吗?
我试过了
<Image source={{uri:'file:///data/data/com.sampleproject/files/blankProject2/0.1/img/sample.jpeg'}} style={{width: 300, height: 300}}/>和
<Image source={{uri: 'img_sample.jpeg'}} />两种情况都失败了。
发布于 2018-02-19 10:09:02
如果你使用的是Android,你应该像这样从资源中加载图片:
<Image source={{uri: 'asset:/app_icon.png'}} style={{width: 40, height: 40}} />使用asset:/作为图像名称的前缀
https://stackoverflow.com/questions/42120879
复制相似问题