简体   繁体   English

ext js这个参数

[英]ext js this argument

In ext-js, what is the difference between doing: 在ext-js中,两者之间有什么区别:

this.combo= new Combo(....)

and

var combo = new Combo().

Also...is there a debugger, System.out.print kind of functionality in ext js whereby I can see what is the object contained in 'this' at any moment? 另外...在ext js中是否有调试器System.out.print类的功能,通过它我可以随时查看'this'中包含的对象是什么?

Console.log() in chrome developer's tool or firefox's firebug its equivalent to System.out.print chrome开发人员工具或firefox萤火虫中的Console.log()等效于System.out.print

If you're in a function then "var" will create a local variable, else its on the global scope. 如果您使用的是函数,则“ var”将创建一个局部变量,否则将在全局范围内。 As far as this it works abit different in javascript than in java. this它在JavaScript中的工作原理与在Java中有所不同。 In JavaScript this always refers to the “owner” of the function we're executing, or rather, to the object that a function is a method of. 在JavaScript中,它总是指我们正在执行的函数的“所有者”,或更确切地说,指的是函数作为方法的对象。 Here is a run through of using this in javascript: 这是在javascript中使用this一个贯穿过程:

The this keyword in javascript JavaScript中的this关键字

Just wanted to add to the above answer that, it gets trickier when it comes to events as to what this refers. 只是想补充,它变得棘手,当谈到事件,以什么上面的回答this是指。 By default, this refers to the object that fired the event. 默认情况下, this是指触发事件的对象。 Meaning that say if you have an AJAX request in an object o using Ajax.request ({...}) , this in the success event handler by default refers to the Ajax request object not object o . 这意味着说,如果你有一个对象的AJAX请求o使用Ajax.request ({...}) thissuccess事件处理程序在默认情况下指的是Ajax请求的对象不反对o But, you can always pass a scope parameter while registering your handler function to guarantee what this refers in the handler function. 但是,你总是可以传递一个scope参数,同时注册您的处理函数,以保证什么this是指在处理函数。 Thank you! 谢谢!

For the first question:- this.combo is the current object which fired the event and the var combo is just initialization of a combo box which can be used in the doc. 对于第一个问题: this.combo是触发事件的当前对象,而var组合只是可在文档中使用的组合框的初始化。 Also, there should be consideration which scope you want while using this. 另外,在使用此功能时应考虑要使用的范围。

For the second question:- we can use the debugging options and then the break points to go through what this contains. 对于第二个问题:-我们可以使用调试选项,然后使用断点来检查其中包含的内容。 If you have not put any break point, it by default contains the window object. 如果尚未放置任何断点,则默认情况下它将包含window对象。 在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM