有没有什么包可以让我显示从外部URL加载的SVG图像?
我尝试过使用react-native-svg-image / react-native-svg-uri和它们的分支,但它们都不能正常工作--有没有什么非死包可以完成这项工作?
这是svg-img-uri抛出的示例错误
<SvgUri width="24" height="24" source={{ uri: 'https://cdnjs.cloudflare.com/ajax/libs/flag-icon-css/3.3.0/flags/1x1/ad.svg' }} />
Text strings must be rendered within a <Text> component.
This error is located at:
in RNSVGDefs (at Defs.js:8)
发布于 2021-03-12 16:08:16
react-native-svg现在支持从在线uri显示svg。
import { SvgUri } from 'react-native-svg';
export default () => (
<SvgUri
width="100%"
height="100%"
uri="http://demo.com/assets/your/image.svg"
/>
);
参考https://github.com/react-native-svg/react-native-svg#use-with-content-loaded-from-uri
发布于 2019-05-20 19:00:44
这个url没有任何引号。这可能就是问题所在
<SvgUri
width="24"
height="24"
source={{ uri: 'https://cdnjs.cloudflare.com/ajax/libs/flag-icon-css/3.3.0/flags/1x1/ad.svg'}} />
发布于 2019-05-21 16:42:48
此Github issue可能会对您有所帮助。
如果您仍然不能成功,您仍然可以使用https://www.smooth-code.com/open-source/svgr/playground/将您的SVG文件转换为React Native组件(不要忘记在左侧面板中切换React-native )
https://stackoverflow.com/questions/56219501
复制相似问题