我将 JSON 数据放置在 Expo 项目中的什么位置

Where do I place JSON data in Expo project

在您的应用中拥有资产是否意味着您的应用在使用 expo 构建和部署时将依赖互联网连接?

我的应用程序正在使用 JSON 数据和图像,我不希望用户需要互联网连接才能使用它,但在发布后,如果没有互联网连接它就无法加载,有时甚至会崩溃.

我正在使用 es6 导入来读取资产中的 JSON 并设置 Redux 状态。

编辑:从SDK 24开始,答案已经改变。您现在可以将一些资产捆绑在您的应用程序二进制文件中,不再依赖于 CDN。

来自the documentation

Bundle your assets inside your standalone binary Expo can bundle assets into your standalone binary during the build process so that they will be available immediately, even if the user has never run your app before. This is important if: Your users may not have internet the first time they open your app, or If your app relies on a nontrivial amount of assets for the very first screen to function properly.

参见 the announcement with some neat explanations and graphs here

以下旧的已接受答案: 我决定更改它,因为它不再正确,并且我在 google 搜索中找到了我自己的答案。这样我们就可以避免人们得到错误的信息。

是的,目前您的用户需要互联网连接。如文档中所述,资产当前上传到内容交付网络 (CDN),而不是与您的应用程序打包在一起。引用 the documentation:

In production Each time you publish your app, Expo will upload your assets to Amazon CloudFront, a blazing fast CDN. It does this in an intelligent way to ensure your deploys remain fast: if an asset has not changed since your previous deploy, it is skipped. You don’t have to do anything for this to work, it is all automatically handled by Expo.

我希望他们将来能改变它或让它成为可选的,因为我也对没有互联网连接的应用程序感兴趣。