如何在Dojo 1.7中使用未压缩的文件? [英] How do I use uncompressed files in Dojo 1.7?
问题描述
我创建了一个取决于dojox / data / JsonRestStore的Dojo模块,如下所示:
I've created a Dojo module which depends on dojox/data/JsonRestStore like this:
define("my/MyRestStore",
["dojo/_base/declare", "dojox/data/JsonRestStore"],
function(declare, JsonRestStore) {
var x = new JsonRestStore({
target: '/items',
identifier: 'id'
});
...
这是很好的,但现在我想要加载JsonRestStore代码的未压缩版本,以便我可以调试它,我找不到任何关于如何做到这一点的文档,但是由于有一个名为'JsonRestStore.js.uncompressed.js'的文件,我将代码更改为:
which is fine. But now I want to have the the uncompressed version of the JsonRestStore code loaded so that I can debug it. I can't find any documentation on how to do this, but since there is a file called 'JsonRestStore.js.uncompressed.js' I changed my code to:
define("my/MyRestStore",
["dojo/_base/declare", "dojox/data/JsonRestStore.js.uncompressed"],
function(declare, JsonRestStore) {
...
认为可能会起作用。
我可以看到正在加载的JsonRestStore.js.uncompressed.js文件在FireBug中,但是尝试执行新的JsonRestStore
时会收到错误:
I can see the JsonRestStore.js.uncompressed.js file being loaded in FireBug, but I get an error when trying to do new JsonRestStore
:
JsonRestStore is not a constructor
应该这样吗?
有没有办法配置Dojo来使用所有模块的未压缩版本?这就是我真正想要的,但是如果这是唯一的办法,那么这样做会解决这个问题。
Is there a way of configuring Dojo to use uncompressed versions of all modules? That's what I really want, but will settle for doing it on a per dependency basis if that's the only way.
我找到了一种方法来实现我想做的:将JsonRestStore.js.uncompressed.js文件重命名为JsonRestStore.js。
I've found a way to achieve what I want to do: rename the JsonRestStore.js.uncompressed.js file to JsonRestStore.js.
但是,这似乎有点像一个黑客的解决方法,所以我仍然很想知道是否有更好的方法(例如通过配置)。
However, this seems a bit like a hacky workaround so I'd still be keen to know if there is a better way (e.g. via configuration).
推荐答案
您有两个选项
1)创建自定义构建。自定义构建将输出一个可用于调试的未压缩文件。想想dojo.js.uncompressed.js,但它包含了您使用的所有额外的模块。
1) Create a custom build. The custom build will output a single uncompressed file that you can use for debugging. Think the dojo.js.uncompressed.js but it includes all the extra modules that you use.
或
2)对于开发环境,请使用dojo源代码。这意味着下载 Dojo Toolkit SDK ,并从开发环境中引用dojo.js。
2) For a development environment, use the dojo source code. This means downloading the Dojo Toolkit SDK and referencing dojo.js from that in the development environment.
对于我工作的项目,我做了两个。我设置了Dojo配置,使其可以是动态的,我可以使用查询字符串参数来更改我想要的配置。
For the projects I work on, I do both. I set up the Dojo configuration so that it can be dynamic and I can change which configuration that I want using a query string parameter.
当我调试问题时,我将使用第一个选项,让我逐步了解代码,看看发生了什么。当我编写一些重要的js时,我使用第二个选项,并且不希望自定义构建的开销看到我的更改。
When I am debugging a problem, I will use the first option just to let me step through code and see what is going on. I use the second option when I am writing some significant js and don't want the overhead of the custom build to see my changes.
我将此更详细地描述
http:// swingingcode.blogspot.com/2012/03/dojo-configurations.html
这篇关于如何在Dojo 1.7中使用未压缩的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!