为什么将图像导入数字


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

最新更新