我正在测试包react-native-chart-kit,我遵循教程只是为了看看它会是什么样子,但我不能让它正常工作。我也尝试了piechart和barchart,但仍然是同样的错误。你能指导我检查一下哪里出了问题吗?
import React from 'react'
import { Text, View, TouchableOpacity, Dimensions } from 'react-native'
import LineChart from 'react-native-chart-kit'
const screenWidth = Dimensions.get("window").width;
const linedata = {
labels: ['January', 'February', 'March', 'April', 'May', 'June'],
datasets: [
{
data: [20, 45, 28, 80, 99, 43],
strokeWidth: 2, // optional
},
],
};
export default function Linechart() {
return (
<View>
<Text>
Bezier Line Chart
</Text>
<LineChart
data={linedata}
width={Dimensions.get('window').width} // from react-native
height={220}
yAxisLabel={'$'}
chartConfig={{
backgroundColor: '#e26a00',
backgroundGradientFrom: '#fb8c00',
backgroundGradientTo: '#ffa726',
decimalPlaces: 2, // optional, defaults to 2dp
color: (opacity = 1) => `rgba(255, 255, 255, ${opacity})`,
style: {
borderRadius: 16
}
}}
bezier
style={{
marginVertical: 8,
borderRadius: 16
}}
/>
</View>
);
}

发布于 2020-10-29 02:31:15
只需将其导入到花括号中即可。
import { LineChart } from 'react-native-chart-kit';每当您看到此错误消息时,最好先怀疑存在错误的import语句。
https://stackoverflow.com/questions/64578409
复制相似问题