作者Ju1ien (Julien)
看板Ajax
标题[问题] 获取上一级物件属性
时间Thu Oct 18 14:10:38 2012
小弟刚接触js不久,问题可能很白痴
先说一个小弟已经知道的,类似这样
function TTest(){
this.v=2;
this.m=TTestM;
}
function TTestM(){
alert(this.v);
}
var t=new TTest();
t.m();//这里this.v就是物件t的属性v
//下面是问题
function TTest(){
this.v=2;
this.subObj=new Object();
this.subObj.m=TTestM;
}
function TTestM(){
alert(this.v);
}
var t=new TTest();
t.subObj.m();
//这里this.v就不对了,问题就是: 在subObj的函式m()里
//能不能获取物件t的属性v﹐不知道有没有讲清楚
//感谢!
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 206.253.164.223