我正在尝试构建dojo1.7,以便在我的phonegap应用程序中使用。我目前使用的是dojo 1.6.1。我通过转到build.dojotoolkit.org并选择dojox.mobile下的所有内容以及一个dojo.store.JsonRest模块来构建当前的dojo.js文件。这很好用。
我的问题是尝试创建一个配置文件来创建一个类似于我从dojo build网站获得的构建。
我下载了dojo 1.7稳定版本src。我从命令行进入buildScripts文件夹,并尝试使用以下命令运行构建:
>build profile=path/myMobileProfile.js action=release releaseName=test我使用了profiles文件夹中的示例配置文件:
dependencies = {
stripConsole: "normal",
layers: [
{
name: "dojo.js",
customBase: true,
dependencies: [
"dojox.mobile.parser",
"dojox.mobile",
"dojox.mobile.compat"
]
},
{
name: "../dojox/mobile/_compat.js",
layerDependencies: [
"dojo.js"
],
dependencies: [
"dojox.mobile._compat"
]
}
],
prefixes: [
[ "dijit", "../dijit" ],
[ "dojox", "../dojox" ]
]
}它在构建时没有任何错误。然后将构建生成的dojo.js放到我的phonegap应用程序中。我将我的索引文件更改为以下内容,只是为了测试:
<!DOCTYPE HTML>
<html>
<head>
<title>PhoneGap</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no"/>
<meta http-equiv="cache-control" content="no-cache"/>
<meta http-equiv="pragma" content="no-cache"/>
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/dojo/1.6/dojox/mobile/themes/android/android.css" type="text/css" media="screen" title="no title">
<script type="text/javascript" src="libs/dojo/dojo/dojo.js" djConfig="parseOnLoad:true"></script>
<script type="text/javascript" charset="utf-8" src="phonegap-1.1.0.js"></script>
</head>
<body style="background-color:white">
Phonegap
</body>
</html>每次我运行这个应用程序时,我都会得到一个白色页面。当我用我的工作副本替换dojo.js文件时,我看到Phonegap输出。
我希望能够使用Dojo1.7mobile和一些新功能,如SpinWheel。
有没有人能帮我做点什么?
谢谢
发布于 2011-12-06 02:05:35
我也有同样的问题。我认为这与新的AMD加载器有关。
解析器似乎没有解析声明性窗口小部件,而是等待按需解析,或者根本不会被调用。
我确实找到了一些文档,提到我们应该使用dojo/ready,但无法让它与它和phoneGap一起工作。同样的代码在没有phoneGap的桌面上运行得很好,这很奇怪。
查看实时文档:http://livedocs.dojotoolkit.org/dojo/ready
以及:http://livedocs.dojotoolkit.org/loader/amd
“要将加载器置于AMD模式,请将异步配置变量设置为truthy:
<script data-dojo-config="async:1" src="path/to/dojo/dojo.js"></script>
<script>
// ATTENTION: nothing but the AMD API is available here
</script>请注意,您只能在加载dojo.js之前设置async标志,并且在AMD模式下,不会自动加载Dojo或任何其他库-加载哪些模块/库完全由应用程序决定。
发布于 2012-03-06 23:45:14
对我来说,这个配置文件在Dojo1.7和PhoneGap上工作得很好:
dependencies = {
selectorEngine: "acme",
layers: [
{
// This is a specially named layer, literally 'dojo.js'
// adding dependencies to this layer will include the modules
// in addition to the standard dojo.js base APIs.
name: "dojo.js",
dependencies: [
"dijit._Widget",
"dijit._Templated",
"dojo.fx",
"dojo.NodeList-fx",
//this wasn't included in the standard build but necessary
"dojo._firebug.firebug",
//my used dojo requirements
"dojox.mobile.parser",
"dojox.mobile",
"dojox.mobile.Button",
"dojox.mobile.SwapView",
"dojox.mobile.ScrollableView",
"dojox.mobile.TabBar",
"dojox.mobile.SpinWheelTimePicker",
"dojox.mobile.compat"
]
}
],
prefixes: [
["dijit", "../dijit" ],
["dojox", "../dojox" ]
]
}但此配置文件不包括CSS文件,因此您必须复制所有CSS文件夹结构。我的HTML文件如下所示:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 5.0//EN" "http://www.w3.org/TR/html5/strict.dtd">
<html>
<head>
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no"></meta>
<meta name="apple-mobile-web-app-capable" content="yes"></meta>
<title>dojox.mobile Demo</title>
<link href="css/themes/iphone/iphone.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="phonegap.js" charset="utf-8"></script>
<script type="text/javascript" src="dojo.js" djConfig="isDebug:true, parseOnLoad:true"></script>
<script type="text/javascript">
require([
"dojox/mobile/parser", // (Optional) This mobile app uses declarative programming with fast mobile parser
"dojox/mobile", // (Required) This is a mobile app.
"dojox/mobile/Button",
//Some other dojo Widgets
"dojox/mobile/compat" // (Optional) This mobile app supports running on desktop browsers
],
function(parser, mobile, compat){
//Optional module aliases that can then be referenced inside callback block
}
// Do something with mobile api's. At this point Dojo Mobile api's are ready for use.
);
//to make sure dojo and PhoneGap was loaded use this
document.addEventListener("deviceready", init(), false);
function init(){
dojo.ready(function(){
//do something
});
}
</script>
</head>
<body>
</body>HTH
发布于 2012-04-21 00:46:31
Dojo 1.7.2解决了这个问题
https://stackoverflow.com/questions/8318505
复制相似问题