我是 coffeescript 和 javascript 的新手,我写了一个简单的代码 =>
1 number = 42
2 coffee = ->
3 ans = confirm "Ready?"
4 "your answer is #{ans}"
我将生成的javascript放入html中,通过单击按钮调用咖啡功能,但它没有显示警报窗口,并且Firebug告诉我“ReferenceError:咖啡未定义”
1 <head>
2 <script type=”text/javascript” src=”http://codeorigin.jquery.com/jquery-1.10.2.js"> </script>
3 <script type="text/javascript" >
4 // Generated by CoffeeScript 1.6.3
5 $(document).ready(
6 function(){
7
8 var coffee, fk, number;
9
10 number = 42;
11
12 coffee = function() {
13 var ans;
14 ans = confirm("Ready?");
15 return "your answer is " + ans;
16 };
17 });
18
19 </script>
20 </head>
21 <body>
22 <input type=button name="lala" value="hihi" onclick="coffee();">
23 </body>