React Native中关于图片引用方式
2018-01-21 本文已影响0人
梦魇_4dcd
图片的引用方式一般分为两种:
1.source={require('xxxxxx.png')}的方式(图1),这种方式一般是引用本地的图片方式,并且不需要指定图片的width和height,并且如果图片在文件夹中区分@2x和@3x的话,不需要在里面require当中体现,系统会自动找对应的图片。Packager打包时会将2x和3x都打包。

2.source={{uri:'xxxxxx'}}的方式(图2和图3),这种方式一般用于加载网络图片,或者是在APP的资源文件包内的文件。如果是资源包里的文件,不需要带后缀名和@2x,系统也会自动去找对应的图片。

