react-native image!{imagename} 是什么意思? [英] react-native what does image!{imagename} mean?

查看:40
本文介绍了react-native image!{imagename} 是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是本机反应的新手.我一直看到 require('image!my-icon'); 这个概念,但我不确定 image! 的确切含义.
文档不提供信息,我的想法是它可能与 react-native 没有特别关系?

I am new to react native. I keep seeing the notion require('image!my-icon'); and i am not sure what image! means exactly.
The docs don't provide info, and my thought is that it might not have to do with react-native specifically?

推荐答案

require('image!my-icon'); 正在使用旧图像加载.这意味着您已经手动将图像添加到您的 android 或 ios 资源文件夹并尝试加载它.此符号表示 JS 打包程序不会尝试管理此图像.

require('image!my-icon'); is using legacy image loading. That means you already manually added image to your android or ios resource folder and trying to load it. This notation says JS packager do not try to manage this image.

请记住 require('image!...') 已弃用,很快将被删除(RN 0.39 或 0.40).在极少数情况下,当您需要直接访问本机图像时,您可以使用 Libraries/Image/

Keep in mind require('image!...') is deprecated and will be removed soon (RN 0.39 or 0.40). In rare cases when you need direct access to native images you can use nativeImageSource from Libraries/Image/

这篇关于react-native image!{imagename} 是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆