回应dvcolgan的澄清评论:Responding to dvcolgan's clarifying comment:因此,您希望在服务器上有一个内嵌CoffeeScript的HTML文件,并使用内联JavaScript作为HTML。 CoffeeScript编译器不直接支持这一点,但你可以使用 coffee-script 库和 jsdom 来执行HTML解析。So, you want to have an HTML file on the server with inline CoffeeScript that gets served as HTML with inline JavaScript. The CoffeeScript compiler doesn't support this directly, but you could write a Node script to do it fairly easily, using the coffee-script library and jsdom to do the HTML parsing.您希望如何实现此操作将取决于Web框架您正在使用。你可能不希望CoffeeScript编译器在每个请求上运行(它相当快,但它仍然会减少你的服务器可以处理的请求数/秒);而是,您希望编译一次HTML,然后从缓存提供编译版本。再次,我不知道有任何现有的工具,但它不应该太难写自己的。Exactly how you want to implement this would depend on the web framework you're using. You probably don't want the CoffeeScript compiler to run on every request (it's pretty fast, but it's still going to reduce the number of requests/second your server can handle); instead, you'd want to compile your HTML once and then serve the compiled version from a cache. Again, I don't know of any existing tools that do this, but it shouldn't be too hard to write your own. 这篇关于是否可以在html文件的脚本标记中编译Coffeescript代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!