"调试" ExtJS脚本 [英] "Debugging" ExtJS script

查看:104
本文介绍了"调试" ExtJS脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有任何特定的工具可用于调试ExtJS脚本?特别是,我发现当屏幕变空时很难进行调试!

解决方案

Aptana Studio 针对Javascript开发进行了优化,包括对Firefox和IE的调试支持,甚至支持先进的Ext JS库(您可能需要分别下载一些eclipse插件)。



Ext JS包含一个 调试控制台 (您需要添加debug.js并调用Ext.log(blah ),这将提供类似Firebug在Firefox上但不是广泛的功能,仍然是有用的补充穷人开发工具 Firebug (这里提到的Ergo)是基于浏览器的开发工具中最强大的(它允许逐步调试),但最新版本的Chrome和Safari也安装了与开发工具是有用的(但不如Firebug)。



我发现在整个应用程序中运行调试跟踪加快了查找错误的过程(见下面的示例)。

  //设置简单的调试工具
DebugManager = function {};
DebugManager.isEnabled = true;
DebugManager.log = function(){
if(DebugManager.isEnabled&&& arguments.length&& console&& console.log){
try {
//单参数?传递给控制台
if(arguments.length == 1)console.log(arguments [0])
//多个参数?将原始参数数组输出到控制台
else console.log(arguments);
} catch(e){}
}
};
//你的函数
函数doSomething(myString){
DebugManager.log(doSomething(myString),myString);
// doSomething的代码
}

然后可以查找控制台trace(Firebug是最好的,因为它输出完整的对象信息),并注意在代码破坏之前执行的最后一个函数。



经过多个月的Ext JS开发,我必须说 Firebug + Aptana Studio combo赢得其他开发工具。


Are there any particular tools available for "Debugging" ExtJS script ? Especially, I findi it difficult to debug when the screen goes blank.!

解决方案

Aptana Studio is optimised for Javascript development, including debug support for Firefox and IE, it even supports type-ahead on the Ext JS library (you might have to download some eclipse plugins separately).

Ext JS comes included with a debugging console (you need to add debug.js and call Ext.log("blah") to bring it up), this will provide functionality that is similar to Firebug on Firefox but not as extensive, still its useful for supplementing the poor development tools that come pre-installed with IE 8. Firebug (as Ergo mentioned here) is the most powerful of the browser-based development tools (it allows step-by-step debugging) however the latest versions of Chrome and Safari also come installed with develoment tools that are useful (but not as much as Firebug).

I find that running a debug trace throughout your application speeds up the process of finding bugs (see example below).

// Setup simple debugging tool
DebugManager = function {};
DebugManager.isEnabled = true;
DebugManager.log = function() {
  if (DebugManager.isEnabled && arguments.length && console && console.log) {
    try {
      // Single parameter? pass it to console
      if (arguments.length == 1) console.log(arguments[0])
      // Multiple parameters? output raw arguments array to the console
      else console.log(arguments);           
    } catch (e) {}
  }
};
// Your function
function doSomething(myString) {
 DebugManager.log("doSomething(myString)", myString);
 // code for doSomething
}

You can then look up the console trace (Firebug is the best since it outputs full object information) and note the last function that executed before your code broke.

After many months of Ext JS development I have to say that Firebug + Aptana Studio combo wins hands down on other tools for development.

这篇关于"调试" ExtJS脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆