1

有谁知道怎么用react-chartjs

我已经导入模块和依赖模块

但还是得到

“未捕获的 ReferenceError:未定义行”

这是我的html文件示例代码

我发现最多的例子是用来another .js file导入它

这是使用 react-chartjs 的唯一方法吗?

<!DOCTYPE html>
<html>
  <head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.2.1/react.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.2.1/react-dom.min.js"></script>
    <script src='https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.5.0/Chart.min.js'></script>
    <script src='https://cdnjs.cloudflare.com/ajax/libs/react-chartjs/0.8.0/react-chartjs.min.js'></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.18.1/babel.min.js"></script>
  </head>
  <body>
    <script type="text/jsx">
    class Test extends React.Component {
        render() {
            var DayData = {
                labels : ['a','b'],
                datasets : [
                    {
                    data : [1,2]
                    }
                ]
            };
            var options={
                responsive: false};
            return (
                <div>
                    <Line id='b' name='a' data={DayData} redraw/> 
                </div>
            );
        }
    }
    ReactDOM.render(
        <Test/>,
        document.getElementById('Test')
    );
    </script>
    <div id="Test">Test</div>
  </body>
</html>

4

0 回答 0