class - 如何将类之间的依赖关系管理到 coffeescript 项目中

标签 class coffeescript dependencies

示例:

  • B级

  • A 类扩展 B 类

命令:coffee -w -j main.js -c -l -o lib src

错误:未捕获类型错误:无法读取未定义的属性“原型(prototype)”

原因 : ClassA 在编译文件中先于 B 编译,所以 classB 还不存在 ClassA 已创建并尝试扩展它..

愚蠢的修复:ClassA重命名为ClassC,因此在编译文件中将在ClassB之后编译

有人得到了更好的修复?

谢谢!

最佳答案

coffeescript documentation 所述:

-j, --join [FILE]
Before compiling, concatenate all scripts together in the order they were passed, and write them into the specified file. Useful for building large projects.

这意味着您必须以正确的顺序传递脚本。假设classA在文件classA.coffee中,classB在文件classB.coffee中,上面的命令应该是:

coffee -w -j main.js -c -l -o lib src/classB.coffee src/classA.coffee

关于class - 如何将类之间的依赖关系管理到 coffeescript 项目中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14217145/

相关文章:

swift - 如何在 Swift 类内部的函数中使用类名

c++ - 使用 std::thread 操作类成员

javascript - Coffeescript:为什么这个类中的这个函数说它的参数未定义?

d3.js - 如何正确地使文本宽度达到图形栏上方的中心标签?

java - Maven BOM [Bill Of Materials] 依赖

java - Maven 暂时依赖未引入

c++ - 将对象加载到指向对象的指针数组中

c++ - eclipse C++。包含带有类的 .h 文件。 "Symbol ' [类 ]' could not be resolved"

javascript - NodeJS 并发/异步生成 View 以提高性能

java - 我们如何更改 Java 项目的 pom.xml 中定义的特定依赖项的位置?