我安裝了「Mindscape Web Workbench」visual studio擴展,並添加了來自Nuget的LessCoffee引用。從Asp.Net中的* .coffee文件運行coffeescript
在我的頁面中,我寫了這些代碼,它正在運行。
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
<script src="http://jashkenas.github.com/coffee-script/extras/coffee-script.js" type="text/javascript"></script>
<script type="text/coffeescript">
@fonksiyon =() -> alert "I knew it!"
@myalert=(myText)-> alert myText
</script>
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<input type="button" id="deneme" onclick="fonksiyon()" value="Deneme" />
<br />
<input type="button" id="Button1" onclick="myalert('yazi veya uyari')" value="Deneme" /> </asp:Content>
我想從 「Coffee1.coffee」 運行相同的代碼,所以我寫了這個:
在CoffeeScript.coffee@fonksiyon =() -> alert "I knew it!"
@myalert=(myText)-> alert myText
在Asp.net頁面
:
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
<script src="http://jashkenas.github.com/coffee-script/extras/coffee-script.js" type="text/javascript"></script>
<script src="CoffeeScript1.coffee" type="text/coffeescript"></script>
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<input type="button" id="deneme" onclick="fonksiyon()" value="Deneme" />
<br />
<input type="button" id="Button1" onclick="myalert('yazi veya uyari')" value="Deneme" />
</asp:Content>
但是這段代碼不起作用。
CoffeeLess添加的web.config:
<httpHandlers>
<add path="*.coffee" type="DotSmart.CoffeeScriptHandler, LessCoffee" verb="*" validate="false" />
<add path="*.less" type="DotSmart.LessCssHandler, LessCoffee" verb="*" validate="false" />
<add path="*.less.css" type="DotSmart.LessCssHandler, LessCoffee" verb="*" validate="false" />
</httpHandlers>
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<add path="*.coffee" type="DotSmart.CoffeeScriptHandler, LessCoffee" verb="*" name="DotSmart.CoffeeScriptHandler" />
<add path="*.less" type="DotSmart.LessCssHandler, LessCoffee" verb="*" name="DotSmart.LessCssHandler" />
<add path="*.less.css" type="DotSmart.LessCssHandler, LessCoffee" verb="*" name="DotSmart.LessCssHandler2" />
</handlers>
</system.webServer>
我與螢火蟲controled並返回此錯誤:
:調用方法時 '的SyntaxError在第4行的保留字 「功能」':[nsIDOMEventListener: :爲handleEvent] [打破這個錯誤]
過濾URL鉻鉻://firebug/content/net/spy.js
我應該怎麼辦?
謝謝。
作爲一個旁註,根本不回答你的問題。我建議現在使用Mindscape Web Workbench for LESS。在此之前,我使用了Duncan的解決方案,它非常出色,但Workbench突出顯示等。 – 2012-02-03 02:12:42