如何在Expo SDK 40 React Native with TypeScript中使用SVG



我尝试在exposdk 40 width:areact native svg transformer 中使用svg

以下是我遵循的过程:

  • expo-init测试(带导航的typescript模型(
  • https://github.com/kristerkari/react-native-svg-transformer

我收到一个错误,说:它应该是字符串类型,但收到了一个数字

我想使用这个svg:logiciel adobe 的vsg绘图示例

在SDK 40之前,该过程是有效的感谢您的帮助!

Expo SDK 40 中的SVG

react-native-svg允许您在应用程序中使用SVG,并支持交互性和动画。

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>
);
}

如何在React Native中使用带有Typescript的svg文件单击此处

最新更新