我使用Chartist庫的圖表使用樣板代碼。唯一的適度是我添加出口上課前:在反應中導出類
import React from 'react';
import ReactDOM from 'react-dom';
import ChartistGraph from '../index';
export class Pie extends React.Component {
render() {
var data = {
labels: ['W1', 'W2', 'W3', 'W4', 'W5', 'W6', 'W7', 'W8', 'W9', 'W10'],
series: [
[1, 2, 4, 8, 6, -2, -1, -4, -6, -2]
]
};
var options = {
high: 10,
low: -10,
axisX: {
labelInterpolationFnc: function(value, index) {
return index % 2 === 0 ? value : null;
}
}
};
var type = 'Bar'
return (
<div>
<ChartistGraph data={data} options={options} type={type} />
</div>
)
}
}
當我嘗試使用導入的成分在我父組件:
import {Pie} from '../components/dashboardChart';
我收到以下錯誤:
54:28-41 "export 'default' (imported as 'ChartistGraph') was not found in '../index'
任何想法是什麼造成這種情況?
您是否反對使用'出口默認餡餅延伸React.Component'? – Andrew