我想在网站中使用coffeescript,但有些东西似乎不起作用。我的 CoffeeScript 位于外部文件中,它链接到 html 文件。我将 CoffeeScript 编译器也链接到了 html 文件。怎么了?
HTML:
<html>
<head>
<script type="text/javascript" src="coffee-script.js"></script>
<script src="jquery-1.10.2.min.js"></script>
<script type='text/coffeescript' src='Test.coffee'></script>
</head>
<body>
</body>
</html>
CoffeeScript :
$->
random = (number) ->
console.log Math.ceil(Math.random() * number)
$("body").append(number)
random(2)
最佳答案
在发布之前尝试将您的 Coffeescript 编译为 Javascript:
Once installed, you should have access to the coffee command, which can execute scripts, compile .coffee files into .js, and provide an interactive REPL.
关于javascript - 你如何使用 CoffeeScript ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21535371/