我已将相同图像的版本 (@2x @3x) 添加到 src>assets 以在所有设备上运行我们的平台。这是问题所在,VSCode 仅识别即 path.png(它不识别 @2x 和 @3x)。我们如何处理这个问题?
最佳答案
React native 会自动从 3 个可用选项中选择所需的图像,即 1x、2x、3x。我们只需提供基本图像的文件名。
示例
.
├── button.js
└── img
├── check.png
├── check@2x.png
└── check@3x.png
因此,如上所述,当您必须使用支票图像时,只需为 check.png 提供图像路径,其余部分将根据 android 和 ios 设备的设备屏幕密度由 react native 自动处理。< br/> 像下面一样使用图像,一切都像魅力一样。
<Image source={require('./img/check.png')} />
More you can read here about the images from react native official docs.
我希望这会有所帮助....谢谢 :)
关于android - 如何将@2x @3x 图像集成到 React Native 项目(Android 和 IOS)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59026204/