简体   繁体   中英

How can I import a javascript library in CoffeeScript?

When I am loading my page I include a javascript library that is used to create graphs with the Google api. I am handling this with CoffeeScript in the front end. According to the tutorial I am initiating the library like: data = new google.visualization.DataTable(); .

When I am parsing my produced JS code from CoffeeScript with JSHint I am getting an error that google is not defined. How can I show to the parser that the library is actually loaded and the object exists?

data = new google.visualization.DataTable();

PROBLEM:
'google' is not defined.

I have tried to call it from the window object like

data = new window.google.visualization.DataTable();

and it stopped complaining.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM