我把所有静态图像都放在项目根目录下名为"images"的文件夹中.但是,在我运行以下命令Bundle 我的应用程序后,该应用程序可以工作,但没有显示任何图像.

我用来Bundle 的命令:

./react-native bundle --minify --entry-file index.ios.js --platform ios --dev false --bundle-output main.jsbundle --assets-dest ./assets

请注意,"assets资源 "文件夹已创建,其中"我的图像"文件夹中的"所有图像"均已确定.

你能帮忙吗?

推荐答案

assets资源 的目的地和主要目的地.jsbundle必须位于同一文件夹中.try :

./react-native bundle --minify --entry-file index.ios.js --platform ios --dev false --bundle-output ./release/main.jsbundle --assets-dest ./release

bundler将在其中创建一个assets文件夹.

UPDATE包括以下讨论中的信息:

The react-native-xcode.sh script that is executed in a XCode build step copies the main.jsbundle and the assets folder created by the bundler into the app package. If you want to deploy the package manually you need to make sure, that those files are copied. The easiest way is to include the main.jsbundle directly into the project and create a folder link to the assets folder. Verify that both are showing up in 'Build Phases' -> 'Copy Bundle Resources'.

React-native相关问答推荐

如何在EXPO路由中重置导航

Reaction-原生NavBottom设计背景

类似Snapchat的Reaction Native筛选器

@testing-library/react-native -> 渲染 -> TypeError:无法读取未定义的属性(读取存在)

GetStream:更改消息气泡背景

Javascript setTimeout 立即在 React Native 中运行

判断状态对象是否为空

react-native redux 和 ListView

react native foreach 循环

由于依赖关系,在 run-android 上构建失败

React Native 中如何使用 Flex 居中组件?

元素中缺少main.jsbundle、Foundation和Security,导致报错

使用 React Native 打开 iOS iPad 模拟器

如何在 React Native 中按住以 Select 文本

自定义原生基础的选项卡

使用 WSL2 运行时如何将手机连接到 expo

如何在 React Native 中等待 Alert 对话框的响应?

React 本机矢量图标在当前版本 0.60 上不起作用

React Native:文本 node 的 Auto宽度

React 在任何根目录中都找不到入口文件