首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Morris.js on node.js未找到

Morris.js on node.js未找到
EN

Stack Overflow用户
提问于 2017-08-24 02:19:24
回答 1查看 391关注 0票数 0

我试着在我的网站上使用morris.js,在官方网站上他们有一个简单的例子:我遵循的morris.js,用npm安装软件包,但是,在我的html莫里斯找不到,我没有从控制台得到任何错误,只是什么都看不到,谁知道会发生什么?我使用的是node.js 0.10,这是我的代码:

(我使用的是单页应用程序)

index.html

..。

代码语言:javascript
复制
    <!-- 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

代码语言:javascript
复制
       <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

结果在我的页面上是一个空白。

EN

回答 1

Stack Overflow用户

发布于 2017-08-24 02:26:54

文档中说您不需要实例化Morris.Line,您应该使用

Morris.Line({element: 'myfirstchart'...})

参见:http://jsbin.com/uqawig/441/embed?js,output

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45851943

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档