我想使用SVG图像react-native.早些时候它不受支持.但是通过查看react-native的源代码,它似乎现在得到了支持.
这是我的示例代码:
class SVGImageSample extends Component {
render() {
return (
<Image source={require("./Mysvg.svg")} style={{height:40,width:40}}/>
);
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的svg图片
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 500 500" height="100" style="enable-background:new 0 0 500 500;" xml:space="preserve">
<style type="text/css">
.st0{display:none;fill:#E0E0E0;}
.st1{display:none;}
.st2{display:inline;fill:#848484;}
.st3{display:none;fill:#FFFFFF;}
.st4{fill:#C22227;}
</style>
<rect id="XMLID_8_" x="-221.1" y="-49" class="st0" width="860" height="596.7"/>
<g id="XMLID_4_" class="st1">
<rect id="XMLID_2_" x="-38.8" class="st2" width="577.5" height="10"/>
<rect id="XMLID_5_" …
Run Code Online (Sandbox Code Playgroud) react-native ×1