图像资源从react-native应用程序中消失 [英] Image resources disappearing from react-native app
问题描述
我有一个奇怪的问题,我无法弄清楚原因。我有一个用react-native创建的应用程序,我正在使用react-native-navigation来处理导航。问题是我从计算机上拔下设备后,我添加到按钮,标签等的图像消失了。
I'm having a strange problem that I cant quite figure out the reason for. I have an app created in react-native and I'm using react-native-navigation to handle the navigation. The problem is that the images I add to buttons, tabs, etc disappear after I unplug my device from the computer.
说清楚;当我连接到计算机并使用应用程序时,我的所有按钮都有图标,但是一旦我从计算机断开连接并打开应用程序,每个图标都会消失。
To make it clear; all my buttons have icons while I'm connected to the computer and use the app, but once I disconnect from the computer and open the app every icon disappears.
这是如何加载图像
Navigation.startTabBasedApp({
tabs: [
{
label: 'One',
screen: 'Screen1',
icon: require('./images/icon1.png'),
selectedIcon: require('./images/icon1_selected.png'),
title: 'Screen One'
},
{
label: 'Two',
screen: 'Screen2',
icon: require('./images/icon2.png'),
selectedIcon: require('./images/icon2_selected.png'),
title: 'Screen Two'
}
]
});
有关此问题的任何想法或帮助吗?
any ideas or help on this issue?
推荐答案
评论中的纯粹猜测,但结果是 react-native run-android
不会自动捆绑您的资产,因为它是开发构建。如果您需要在完全断开与计算机的连接时测试构建,可以使用 - variant = release
使用发布版本进行安装,因为它总是会将您的资产与apk捆绑在一起。
Pure guesswork in the comments, but turned out that react-native run-android
doesn't automatically bundle your assets as it's a development build. If you need to test the build while completely disconnected from your computer, you can install using a release build using --variant=release
as that will always bundle your assets with the apk.
这篇关于图像资源从react-native应用程序中消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!