如何解决SVG组件未显示在React Native ImageBackground组件中
我在react native中创建了一个SVG组件,用作文本和其他图像的父组件。在将组件呈现为字符串之后,我决定使用ImageBackground组件。
function SubCard() {
// component to string
const imageString = encodeURIComponent(renderToStaticMarkup(<SubCardPanel width={300} fill='#000' />));
const image = { uri: `data:image/svg=xml;utf8,${imageString}` }
return (
<View styles={styles.container}>
<ImageBackground source={image} style={styles.image}>
<Text>jnsnaldnaskln</Text>
</ImageBackground>
</View>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,flexDirection: "column"
},image: {
flex: 1,justifyContent: "center",resizeMode: "cover"
}
})
/*const BgContainer = styled.View`
background-image:
`
*/
我没有任何错误...但是没有显示图片...。只是文字。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。