浏览:2872008-04-12 14:27   来自(NineTyNine)      :
有谁能帮忙讲讲js中的this
楼主
  1个月前   小三儿      :
this主要用于对象定义中,用以指代自己。在较为简单的网页设计中,因为较少涉及大型对象,主要用于a等元素,实现对CSS效果的补充。
回复  1楼 回到顶楼 
  1个月前   红色枫叶      :
指当前对象
回复  2楼 回到顶楼 
  3周前   whwqs      :
可以看看js框架prototype中Function的bind方法
Function.prototype.bind = function() {
var __method = this, args = $A(arguments), object = args.shift();
return function() {
return __method.apply(object, args.concat($A(arguments)));
}
}
回复  3楼 回到顶楼 
  3周前   棕熊      :
随便写了点,楼主可以参考下:
http://www.cnblogs.com/ruxpinsp1/archive/2008/04/20/1162463.html
回复  4楼 回到顶楼 
  3周前   Herman.Wong      :
this.id,this.**
this=对象本身.
回复  5楼 回到顶楼 
  3周前   5yplan      :
随便写两个,很乱!
回复  6楼 回到顶楼 
  3周前   5yplan      :
//0
function a(){
this.a = "a";
}
alert((new a()).a)

//1
var __aa = null;
function aa(){
__aa = this;
alert(this == window);
}
aa();
var _aa = new aa();
alert(_aa === __aa);

//2,
var b = {
a:function(){
return this.value;
},
value:"value"
}
alert(b.a());

//3
function c(){
function cc(){
this.value ="window";
};
//直接执行函数,那么函数内部this == window,所以window.value="123";
cc();
this.value2 = "new object";
}
//创建c的实例,所以上面this.value2中this,为新创建的实例
var instantC = new c();
alert(window.value);
alert(instantC.value2);
回复  7楼 回到顶楼 

你还不是小组成员,加入小组以后才能发布新主题!
> 返回“ASP.NET”


其他话题

1 24851