Meteor不会加载客户端库

时间:2013-12-03 01:10:19

标签: meteor libraries typeerror

我正在尝试在流星项目中使用DevExpress的chartjs,我无法加载所需的客户端库。在我的项目目录中,我有一个包含两个项目的'client'文件夹; dx.chartjs和globalize.min

我在加载页面时收到两个错误:

Uncaught TypeError: Cannot read property 'DevExpress' of undefined

Exception from Deps afterFlush function: TypeError: Object [object Object] has no method 'dxPieChart'
    at Object.Template.hello.rendered (http://localhost:3000/chart.js?15ecf0e00ba2737900c70309ae9e83a5e6402b17:15:22)
    at Spark.createLandmark.rendered (http://localhost:3000/packages/templating.js?3e5f495522f23490e6711696b729358477f2105b:181:42)
    at http://localhost:3000/packages/spark.js?89d98339d0de8299aab5a40fa82010709f0606ee:443:32
    at Array.forEach (native)
    at Function._.each._.forEach (http://localhost:3000/packages/underscore.js?ab3604ad6a217062906fb40c8236bb7e59f51a7f:130:11)
    at http://localhost:3000/packages/spark.js?89d98339d0de8299aab5a40fa82010709f0606ee:441:7
    at _.extend.flush (http://localhost:3000/packages/deps.js?3ca61f7bda24db4f00839466f22fd1d61de37661:265:11)

我的代码非常简单 HTML文件

<head>
  <title>chart</title>
</head>

<body>
  {{> hello}}
</body>

<template name="hello">
  <div id="chartContainer"/>
</template>

和js文件

if (Meteor.isClient) {

  Template.hello.rendered = function() {
    var dataSource = [
    { country: "Russia", area: 12 },
    { country: "Canada", area: 7 },
    { country: "USA", area: 7 },
    { country: "China", area: 7 },
    { country: "Brazil", area: 6 },
    { country: "Australia", area: 5 },
    { country: "India", area: 2 },
    { country: "Others", area: 55 }
];

$("#chartContainer").dxPieChart({
    size:{ 
        width: 500
    },
    dataSource: dataSource,
    series: [
        {
            argumentField: "country",
            valueField: "area",
            label:{
                visible: true,
                connector:{
                    visible:true,           
                    width: 1
                }
            }
        }
    ],
    title: "Area of Countries"
});
  }

}

我还没有使用其他机器复制此问题。我已经多次卸载并重新安装,没有运气。有没有人遇到或可以说明为什么会出现这种错误?

1 个答案:

答案 0 :(得分:1)

尝试将文件放在client / compatibility目录中。来自文档http://docs.meteor.com/#structuringyourapp

  

某些JavaScript库仅在放入时才有效   客户端/兼容性子目录。