<分区>
Possible Duplicate:
Is there a way to send CoffeeScript to the client's browser and have it compiled to JavaScript there?
<script>
中是否有一种简单的编译 Coffeescript 的方法? html 中的标签,还是您通常将所有 Coffeescript 放在单独的文件中?
标签 html coffeescript
<分区>
Possible Duplicate:
Is there a way to send CoffeeScript to the client's browser and have it compiled to JavaScript there?
<script>
中是否有一种简单的编译 Coffeescript 的方法? html 中的标签,还是您通常将所有 Coffeescript 放在单独的文件中?
最佳答案
确实有。有一个关于它的帖子here .
那篇文章的总结是这样的:
text/coffeescript
在页面头部包含这一行:
<script type="text/javascript" src="https://raw.githubusercontent.com/jashkenas/coffeescript/master/lib/coffee-script/coffee-script.js"></script>
请注意,不鼓励这样做。
<html>
<head>
<title>In-Browser test</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js" type="text/javascript">
</script>
<script src="https://raw.githubusercontent.com/jashkenas/coffeescript/master/lib/coffee-script/coffee-script.js" type="text/javascript">
</script>
</head>
<body>
<script type="text/coffeescript">
$ -> $('#header').css 'background-color', 'green'
</script>
<h1 style="color:white" id="header">CoffeeScript is alive!</h1>
</body>
</html>
关于html - 是否可以在 html 文件的脚本标签中编译 Coffeescript 代码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7860942/