类里的方法为啥取不到初始值~ 本帖最后由 jone_linux 于 2009-07-21 12:27:46 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 initialize: function(ResponseMegDivId) { this._ResponseMegDivId = ResponseMegDivId; // 1 this._DefMeg = { onCreate: function() { alert(this._ResponseMegDivId); // 2 } }; this._AjaxDefMeg(this._DefMeg); },你这两行代码 1 , 2 中的 this 不是同一对象 this._DefMeg = { onCreate: function(v){ return function() { alert(v); } }(this._ResponseMegDivId); }; initialize: function(ResponseMegDivId) { this._ResponseMegDivId = ResponseMegDivId; // 1 this._DefMeg = { onCreate: function() { alert(ResponseMegDivId); // 2 直接显示参数 } }; this._AjaxDefMeg(this._DefMeg); }, LZ要用Prototype的Class,为何有不按其语法写呢 json字符串 yui插件不能正确显示 请帮助查看用document.write总是返回[object]问题的原因 javascript 报缺少十六进制数字的错 应该怎么修改 js calendar 问题 有关javascript遍历问题,请高人帮帮忙~ 设置span的innerText属性报错 一个小问题·请帮忙看看 Table中row的复制问题! 问题没解决,我就给了分。 关于继承的问题 js文件最后加载如何实现【csdn的高人进来】
{
this._ResponseMegDivId = ResponseMegDivId; // 1
this._DefMeg = {
onCreate: function() {
alert(this._ResponseMegDivId); // 2
}
};
this._AjaxDefMeg(this._DefMeg);
},你这两行代码 1 , 2 中的 this 不是同一对象
onCreate: function(v){
return function() {
alert(v);
}
}(this._ResponseMegDivId);
};
{
this._ResponseMegDivId = ResponseMegDivId; // 1
this._DefMeg = {
onCreate: function() {
alert(ResponseMegDivId); // 2 直接显示参数
}
};
this._AjaxDefMeg(this._DefMeg);
},