Cordova应用显示空白页面
cordova app showing blank page
我想开发一个cordova应用程序与多个视图使用一个单一的页面借助车把 javascript库。我用phonegap创建了一个简单的应用程序,命名为MyFirstApp,然后编辑www目录下的index.html文件。但是当我在网络浏览器中运行应用程序时没有显示。有人看出我哪里做错了吗?
index . html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="format-detection" content="telephone=no" />
<meta name="msapplication-tap-highlight" content="no" />
<!-- WARNING: for iOS 7, remove the width=device-width and height=device-height attributes. See https://issues.apache.org/jira/browse/CB-4323 -->
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
<link rel="stylesheet" type="text/css" href="css/index.css" />
<title>Hello World</title>
</head>
<body>
<div class="mainpage">
<!--This is our template. -->
<!--Data will be inserted in its according place, replacing the brackets.-->
<script id="address-template" type="text/x-handlebars-template">
<p>You can find me in {{city}}. My address is {{number}} {{street}}.</p>
</script>
<!--Your new content will be displayed in here-->
<div class="content-placeholder"></div>
</div>
<script src="js/jquery-2.1.4.min.js" type="text/javascript" charset="utf-8"></script>
<script src="js/handlebars-v4.0.2.js"></script>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/index.js"></script>
<script type="text/javascript">
app.initialize();
</script>
</body>
</html>
index.js
var app = {
initialize: function() {
this.bindEvents();
},bindEvents: function() {
document.addEventListener('deviceready', this.onDeviceReady, false);
},onDeviceReady: function() {
// Grab the template script
var theTemplateScript = $("#address-template").html();
// Compile the template
var theTemplate = Handlebars.compile(theTemplateScript);
// Define our data object
var context={
"city": "London",
"street": "Baker Street",
"number": "221B"
};
// Pass our data to the template
var theCompiledHtml = theTemplate(context);
// Add the compiled html to the page
$('.content-placeholder').html(theCompiledHtml);
}
};
使用这个作为你的index.js:
var app = {
initialize: function() {
this.bindEvents();
},bindEvents: function() {
document.addEventListener('deviceready', this.onDeviceReady, false);
},onDeviceReady: function() {
// Grab the template script
var theTemplateScript = $("#address-template").html();
// Compile the template
var theTemplate = Handlebars.compile(theTemplateScript);
// Define our data object
var context={
"city": "London",
"street": "Baker Street",
"number": "221B"
};
// Pass our data to the template
var theCompiledHtml = theTemplate(context);
// Add the compiled html to the page
$('.content-placeholder').html(theCompiledHtml);
}
};
相关文章:
- Facebook共享显示一个接一个的空白页面
- 如果我在javascript中输入无效的电子邮件或空白,如何显示特定的文本框边框红色
- 带有显示XML数据的HTML的空白页
- 谷歌图表显示空白白色页面
- javascript 显示空白灰色层
- 从java调用javascript后显示空白页面
- 当从jquery的点击事件中的每个循环创建的数组到它之外时,它显示空白数组
- Facebook Javascript SDK提要对话框显示空白窗口
- 我想推送$scope.planlist=[]中的空白记录,但显示出相同的行为
- 漫游滑轨只显示空白屏幕
- 回调返回响应,但当在API中发送时,响应在节点JS中显示为空白
- 简单的jqPlot显示为空白
- LinkedIn关注显示空白页的公司按钮
- 在 中显示警告框 asp.net 将重定向到空白页,然后返回到原始页面
- 画布到图像显示为无图像(空白)
- 如何使空白区域可单击以显示文本
- 隐藏元素,但将该位置显示为空白
- 我的网站在移动版式镶版式右侧显示空白区域,但桌面版式版式显示空白区域
- 谷歌地图 - 当地图应该显示时,有时会发生“未定义”错误或地图为空白.如何预防
- 当我打开它时,它会显示一个空白网页