0

尝试使用react-native-svg时出现以下错误:

错误截图

我在我的代码中使用这样的 react-native-svg : 代码截图

我这样称呼组件

import BarChart from './BarChart'

// ...

我正在使用 react-native-svg : 9.13.3 和 expo : 36 我使用 expo install react-native-svg 安装了 react-native-svg 并且我已经尝试使用重置缓存重新启动.....请救救我,哈哈美好的一天 !

4

1 回答 1

0

问题很可能来自您如何导入Svg.

从我找到的文档中,如果您使用的是Expo,那么您需要导入为:

/* Use this if you are using Expo */

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

而不是你的例子:

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

见下Usage节。

于 2020-05-31T09:39:29.983 回答