我试着在我的网站上使用morris.js,在官方网站上他们有一个简单的例子:我遵循的morris.js,用npm安装软件包,但是,在我的html莫里斯找不到,我没有从控制台得到任何错误,只是什么都看不到,谁知道会发生什么?我使用的是node.js 0.10,这是我的代码:
(我使用的是单页应用程序)
index.html
..。
<!-- Morris.js -->
<link rel="stylesheet" href="node_modules/morris.js/morris.css">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-min.js"></script>
<script src="node_modules/morris.js/morris.js"></script>
...
<body>
<div data-ng-view>
</div>
</body>
...page.html
<div id="myfirstchart" style="height: 250px;"></div>
<script>
new Morris.Line({
// ID of the element in which to draw the chart.
element: 'myfirstchart',
// Chart data records -- each entry in this array corresponds to a point on
// the chart.
data: [
{ year: '2008', value: 20 },
{ year: '2009', value: 10 },
{ year: '2010', value: 5 },
{ year: '2011', value: 5 },
{ year: '2012', value: 20 }
],
// The name of the data record attribute that contains x-values.
xkey: 'year',
// A list of names of data record attributes that contain y-values.
ykeys: ['value'],
// Labels for the ykeys -- will be displayed when you hover over the
// chart.
labels: ['Value']
});
</script>node_modules on my

结果在我的页面上是一个空白。
发布于 2017-08-24 02:26:54
文档中说您不需要实例化Morris.Line,您应该使用
Morris.Line({element: 'myfirstchart'...})
参见:http://jsbin.com/uqawig/441/embed?js,output
https://stackoverflow.com/questions/45851943
复制相似问题