【发布时间】:2014-05-12 16:01:33
【问题描述】:
我是 PhoneGap/CoffeeScript 的新手,试图让 Hello World 应用在 iOS 中运行,我想知道我做错了什么。
这将是我的标准 index.html:
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no;" />
<meta charset="utf-8">
<script type="text/javascript" charset="utf-8" src="cordova-1.6.0.js"></script>
<script type="text/javascript" charset="utf-8" src="app.js"></script>
</head>
<body onload="onBodyLoad()">
<h1>Hey, it's Cordova!</h1>
<p>Don't know how to get started? Check out our <em><a target="_blank" href="http://docs.phonegap.com/en/edge/guide_getting-started_ios_index.md.html#Getting%20Started%20with%20iOS">Getting Started Guide</a></em>
</body>
</html>
从 app.coffee 生成的 app.js 看起来像这样:
(function() {
var onBodyLoad, onDeviceReady;
onBodyLoad = function() {
return document.addEventListener("deviceready", onDeviceReady, false);
};
onDeviceReady = function() {
return navigator.notification.alert("This alert never happens!");
};
}).call(this);
当我删除 app.js 的第一行“(function() {”和最后一行“}).call(this);”时警报和一切工作正常。 但我想有一个比每次 CoffeeScript 编译成 JavaScript 时删除这些行更好的方法。
非常感谢, 雅各布
【问题讨论】:
标签: cordova coffeescript