[英]react-chartjs integration error. Cannot read property 'xLabels' of undefined
[英]react-chartjs error Cannot read property 'Chart' of undefined
我已經安裝了react-chartjs。 當按照說明進行測試時,我得到一個錯誤,無法在第10行Chart.js讀取未定義的屬性'Chart'
這是我的代碼
var React = require('react');
var Chart = require('chart.js');
var LineChart = require("react-chartjs").Line;
var LineChart = React.createClass({
render: function() {
return <LineChart width="600" height="250"/>
}
});
module.exports = LineChart;
我很困惑,無法在線找到任何解決方案。 感謝您的任何評論
您正在兩次聲明LineChart
。 更改其中一個的名稱,例如:
var MyChart = React.createClass({ /* rest of your code */ });
module.exports = MyChart;
我也有同樣的問題,'npm cache clean'有幫助! 它可能與chartjs和react-chartjs的依賴關系有關。
我有同樣的問題。 Webpack構建中排除node_modules有所幫助。 看看這個https://github.com/jhudson8/react-chartjs/issues/93 。
這是webpack.config.js
的示例“模塊”部分:
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /(node_modules)/,
loader: 'babel-loader'
}
]
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.