Javascript SVG组件未显示在React Native ImageBackground组件中
我在react native中创建了一个SVG组件,用作文本和其他图像的父组件。在将组件呈现为字符串后,我决定使用ImageBackground组件Javascript SVG组件未显示在React Native ImageBackground组件中,javascript,reactjs,image,svg,native,Javascript,Reactjs,Image,Svg,Native,我在react native中创建了一个SVG组件,用作文本和其他图像的父组件。在将组件呈现为字符串后,我决定使用ImageBackground组件 function SubCard() { // component to string const imageString = encodeURIComponent(renderToStaticMarkup(<SubCardPanel width={300} fill='#000' />)); const image =
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:
`
*/
函数子命令(){
//组件到字符串
const imageString=encodeURIComponent(renderToStaticMarkup());
const image={uri:`data:image/svg=xml;utf8,${imageString}`}
返回(
jnsnaldnaskln
);
};
const styles=StyleSheet.create({
容器:{
弹性:1,
flexDirection:“列”
},
图片:{
弹性:1,
辩护内容:“中心”,
resizeMode:“封面”
}
})
/*const BgContainer=styled.View`
背景图像:
`
*/
我没有错误。。。但从图像上看,它并没有出现。。。。只有文本