import image from './image.png';
console.log(image) // returns some number
为什么在React Native中导入图像?
require
react Native中的图像将映射为一个数字。
在@types/react-native
中,React本地打字稿声明,我们可以显示如下。
export type ImageSourcePropType = ImageURISource | ImageURISource[] | ImageRequireSource;
...
export type ImageRequireSource = number;
ImageRequireSource
只是number
类型的别名,它可以是ImageSourcePropType
。