我想将图像传递给React Native组件。什么是图像资源的类型?
import image from './avatar.png'
type Avatar = {
img: ??? // what is the type of image resource?
};
const Avatar = ({ img }: Avatar) => (<Icon img={img}>)
谢谢@Dan。你是对的。
type Avatar = {
img: number
};
在RN中,我们经常使用require('imagepath')
作为Image组件的源。如下所示,require('imagepath')
返回的类型是number
。我刚试过,它有效。