我想将图像传递给React Native组件。图像资源的类型是什么?
import image from './avatar.png'
type Avatar = {
img: ??? // what is the type of image resource?
};
const Avatar = ({ img }: Avatar) => (<Icon img={img}>)
答案 0 :(得分:0)
感谢@Dan。你是对的。
nodes = [
['ID', 'Label', 'Color'],
[0,'WAKA WANNA BE SOURCE','#F27420'],
[1,'WAKA WANNA BE TARGET','#4994CE'],
[2,'WAKA DON\'T KNOW WHO WANNA BE','#FABC13'],
]
links = [
['Source','Target','Value','Link Color'],
[0,1,10,'rgba(253, 227, 212, 1)'],
[0,2,10,'rgba(242, 116, 32, 1)'],
[2,1,10,'rgba(253, 227, 212, 1)'],
]
在RN中,我们经常使用type Avatar = {
img: number
};
作为Image组件的来源。如下所示,返回的类型require('imagepath')
是require('imagepath')
。我刚刚尝试过,它有效。