简体   繁体   English

如何在 Expo SDK 40 中使用 SVG 与 Z558B544CF68335F39D386EZC403 反应原生?

[英]How to use SVG in Expo SDK 40 React Native with TypeScript?

I tried to use a svg in expo sdk 40 width: react-native-svg-transformer我尝试在 expo sdk 40 中使用 svg 宽度:react-native-svg-transformer

Here is the process i followed:这是我遵循的过程:

I got an error saying: it was expected string type but received a number我收到一条错误消息:这是预期的字符串类型,但收到了一个数字

I want to use this svg: example vsg drawing by logiciel adobe我想使用这个 svg:由 logiciel adobe 绘制的示例 vsg 绘图

Before the SDK 40, the process was working Thanks for Help !在 SDK 40 之前,该过程正在运行 感谢您的帮助!

SVG in Expo SDK 40 SVG 在 Expo SDK 40

react-native-svg allows you to use SVGs in your app, with support for interactivity and animation. react-native-svg允许您在应用程序中使用 SVG,支持交互性和 animation。

expo install react-native-svg


import * as React from 'react';
import Svg, { Circle, Rect } from 'react-native-svg';

export default function SvgComponent(props) {
  return (
    <Svg height="50%" width="50%" viewBox="0 0 100 100" {...props}>
      <Circle cx="50" cy="50" r="45" stroke="blue" strokeWidth="2.5" fill="green" />
      <Rect x="15" y="15" width="70" height="70" stroke="red" strokeWidth="2" fill="yellow" />
    </Svg>
  );
}

How to use svg files in React-Native with Typescript Click here如何在 React-Native 和 Typescript 中使用 svg 文件点击这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 未找到 react-native-svg ForeignObject 元素(React-Native + Expo + TypeScript) - react-native-svg ForeignObject element not found (React-Native + Expo + TypeScript) 如何在Typescript中使用React Native? - How to use React Native with Typescript? 如何使用 Typescript 为 React Native Expo dev 做 AuthContext,createDataContext? - How to do AuthContext, createDataContext using Typescript for React Native Expo dev? 如何使用 TypeScript 调试用 Expo 创建的 React Native 项目 - How to debug React Native project created with Expo using TypeScript Expo SecureStore 未正确保存(React native、typescript) - Expo SecureStore not saving correctly (React native, typescript) 图像不适用于React Native + TypeScript + Expo - Images are not working with React Native + TypeScript + Expo 将TypeScript添加到React-Native Expo项目 - Adding TypeScript to React-Native Expo project 如何在Typescript中使用react-native-web - How to use react-native-web with Typescript ESLint (Airbnb) + TypeScript 中 React Native (Expo) 的 Prettier 设置 - ESLint (Airbnb) + Prettier setup for React Native (Expo) in TypeScript React Native with typescript - 如何使用来自@react-navigation/native 的 useRoute with typescript - React native with typescript - how to use the useRoute from @react-navigation/native with typescript
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM