Proper way to access third party libs such as D3 in Ember CLI? [closed]

夙愿已清 提交于 2019-12-23 15:36:54

问题


Here is how I've done:

bower install d3 --save

then added to Broccoli.js:

app.import('bower_components/d3/d3.js');

then in my view, added:

import d3 from 'bower_components/d3/d3';

and attempted to use it.

This causes an issue when launching the app. In devtools I see this error:

Uncaught TypeError: Cannot read property 'length' of undefined  vendor.js:40
Module   vendor.js:52
define   vendor.js:88532
(anonymous function)   vendor.js:88534
(anonymous function)   

So I'm guessing that I'm including it the wrong way.

I'm trying to avoid adding stuff to .jshintrc and making all import explicit instead, but no luck so far. So I tried that too:

Don't import d3 in my module, and instead just add d3 to jshint's predef. No luck either, same issue.

How have you guys been doing this?

Thanks!


回答1:


I had the wrong loader.js version installed. Should be 1.0.1, and I had 2.1.1. Now everything works!



来源:https://stackoverflow.com/questions/27278368/proper-way-to-access-third-party-libs-such-as-d3-in-ember-cli

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!