草庐IT

externalObject

全部标签

javascript - 使用 coffeescript 公开一个 javascript api

我最近开始使用coffeescript,并且很好奇将我使用Coffeescript创建的对象公开给其他javascript页面的“正确”方法是什么。由于coffeescripts包装功能,调用window.coffeeObject=externalObject是否可以接受。例子example.coffeeexternalObject=method1:->'Returnvalue'method2:->'Returnmethod2'window.myApi=externalObjectexample.js--从example.coffee编译(function(){varexternalO