React native 为什么图像作为数字导入?

React native 为什么图像作为数字导入?,react-native,React Native,为什么在React Native中将图像作为数字导入?需要React Native中的图像将作为数字映射 在@types/react nativereact native Typescript声明中,我们可以如下所示 import image from './image.png'; console.log(image) // returns some number ImageRequireSource只是number类型的别名,它可以是ImageSourcePropType图像不能使用。试试这

为什么在React Native中将图像作为数字导入?

需要
React Native中的图像将作为数字映射

@types/react native
react native Typescript声明中,我们可以如下所示

import image from './image.png';
console.log(image) // returns some number

ImageRequireSource
只是
number
类型的别名,它可以是
ImageSourcePropType

图像不能使用。试试这个:
。我想,这个数字可能与图像的散列码有关。
source={image}
确实有效,但不知为什么。inline
require
给出了一个eslinter错误OK,你能解释一下你的错误是什么,添加一些上下文、日志等吗?现在还不清楚你想达到什么目的,这不是错误。日志是我在代码中指出的一些数字。我只是想了解它背后的理论(即为什么它与react.js的工作方式不同)
export type ImageSourcePropType = ImageURISource | ImageURISource[] | ImageRequireSource;
...
export type ImageRequireSource = number;