【发布时间】:2018-09-24 16:33:18
【问题描述】:
假设我有一个组件<MyComponent /> that takes in prop calledsrcthesrcprop can take insvgas well as aimg`
<MyComponent src={someSvgComponent} />
或者
<MyComponent src={someImgComponent} />
如何检查src 中传递的道具是图像还是svg?图像的类型可以是 jpeg|jpg|png|gif
现在src 属性可以传递文件或文件的路径。
【问题讨论】:
-
文件是指 base 64 编码的 svg/img 数据?
-
是的,我的意思是文件。
标签: javascript reactjs svg