कॉफ़ीस्क्रिप्ट कंपाइलर किसी कारण से, मेरे सभी कॉफ़ी फ़ाइलों को संकलित करते समय फ़ंक्शन में लपेटता है। उदाहरण के लिए, अगर मैं test.coffee है:फ़ंक्शन में कॉफ़ीस्क्रिप्ट रैपिंग फ़ाइलें
class TestClass
constructor: (@value) ->
printValue:() ->
alert(@value)
printAValue =() ->
test = new TestClass()
test.printValue()
तो मैं मिल test.js:
(function() {
var TestClass, printAValue;
TestClass = (function() {
function TestClass(value) {
this.value = value;
}
TestClass.prototype.printValue = function() {
return alert(this.value);
};
return TestClass;
})();
printAValue = function() {
var test;
test = new TestClass();
return test.printValue();
};
}).call(this);
मेरे सरल html फ़ाइल इस के साथ काम नहीं करेगा:
<html>
<head>
<script src="test.js"></script>
</head>
<body onload="printAValue()">
</body>
</html>
मैं पहले जेएस के साथ काम नहीं किया है, और मुझे कॉफी कंपाइलर पर शक नहीं होगा, लेकिन जिस तरह से इसे काम करना चाहिए? कैसे
टेस्ट क्लास प्रारंभकर्ता -'test = नया टेस्टक्लास ('हैलो वर्ल्ड') ' – arunkumar
पर मान पास करने के लिए अपनी कॉफ़ीस्क्रिप्ट लाइन को बदलने का प्रयास करें, [मेरा जवाब यहां] [1] जेएस फाइल/मॉड्यूल के बीच कोड साझा करने पर देखें। [1]: http://stackoverflow.com/questions/6951438/accessing-document-within-coffeescripts-default-wrapper/6951641#6951641 –
यह अब तक का सबसे लोकप्रिय सवाल CoffeeScript के बारे में पूछा जाता है पर इसलिए। Http://stackoverflow.com/q/6481986/66226 देखें, http://stackoverflow.com/q/4214731/66226, http: //stackoverflow.com/q/5693211/66226 ... –