React Native:图像不可见
React Native: image not visible
使用 React Native v0.61.5。
图像(iOS 和 Android)在开发模式下仅在模拟器上或在连接电缆和终端 运行 的 phone 上可见。关闭终端并再次打开应用程序后,图像不可见。
图像代码
<Image source={require("../assets/image.png")} />
我找到的用于将图像从 ./assets 文件夹复制到 /res 的代码:
npx react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/
此代码使用我使用的图像创建文件夹,但是当我关闭终端并断开连接时 phone 图像不可见。
你也遇到过这种情况吗?不用终端也能加载图片怎么办运行?
你应该在
ProjectName/android/app/src/main/res android 和 android 的目录
ios 使用 Images.xcassets 将您的图像拖放到其中。
在此文件夹中添加图像。
像这样访问图片<Image source={{uri:"imagename"}}/>
使用 React Native v0.61.5。 图像(iOS 和 Android)在开发模式下仅在模拟器上或在连接电缆和终端 运行 的 phone 上可见。关闭终端并再次打开应用程序后,图像不可见。
图像代码
<Image source={require("../assets/image.png")} />
我找到的用于将图像从 ./assets 文件夹复制到 /res 的代码:
npx react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/
此代码使用我使用的图像创建文件夹,但是当我关闭终端并断开连接时 phone 图像不可见。
你也遇到过这种情况吗?不用终端也能加载图片怎么办运行?
你应该在 ProjectName/android/app/src/main/res android 和 android 的目录 ios 使用 Images.xcassets 将您的图像拖放到其中。
在此文件夹中添加图像。
像这样访问图片
<Image source={{uri:"imagename"}}/>