reactjs - 如何在 React-Native 中渲染 svg 图像?
问题描述
请尝试帮助我!我需要在 android 和 ios 视图上从我的文件夹“project/assest/images/test.svg”中渲染 svg 图像。
我努力了 :
解决方案 1:<Image source={imagePath}></Image>
解决方案 2:
import SvgUri from 'react-native-svg-uri';
<View>
<SvgUri
width="200"
height="200"
source={{uri:'http://thenewcode.com/assets/images/thumbnails/homer-simpson.svg'}}
/>
</View>
解决方案 3:首先我应该将 svg 文件转换为 png、jpeg 然后渲染简单的图像,但是这种方式非常奇怪
请帮忙,我做错了什么。
解决方案
您还可以尝试SVG 的 react-native-svg包
例如 -
import * as React from 'react';
import { SvgUri } from 'react-native-svg';
export default () => (
<SvgUri
width="100%"
height="100%"
uri="http://thenewcode.com/assets/images/thumbnails/homer-simpson.svg"
/>
);
推荐阅读
- three.js - 三JS编辑器中使用场景的用户数据
- javascript - 在不提供网页的情况下使用 npm 测试 javascript 代码
- javafx - HelloFX.java:1:错误:包 javafx.application.Application 不存在
- mysql - 如何从mysql中的重复数据中只选择一个数据?
- python - 无法在 Visual Studio 代码中安装 twilio
- javascript - 设置 Socket.io 房间变量
- python - 在 python 中下载批量图像
- integration - 带有动态域名的 Docusign 重定向 url
- html - 将 django Authentication 表单与 html 表单一起使用
- python - 如何从查询集中删除而不删除Django中的原始模型本身