解决方案 »
- ajax的send函数怎么总是出错?谁来看看我的代码有什么问题,帮改正下
- 请教精简一段jqery代码
- javascript 链接作为字符串后返回,变量的传递方法?
- 如何将google api 搜索出来的内容输出到html页面
- 请问“this[i+1]=initArray.arguments[i]“是什么意思,还有initArray是函数名,怎么又定义了同名的数组了?请赐教
- 那种论坛主题列表前的"十"字符号被点击时展开并导入别人跟帖的信息是如何做的呀?
- vbscript中有没有向timer控件的功能呢
- 全局数组变量的问题:怎样在function之外获得全局变量的值呢?
- 怎么自动转到别的链接了?(64分)
- jQuery执行现在文件的请求,用什么方法
- 新手求教
- 请大家帮我解决这个题,下午就要考试了,现在还不会
//子类重写父类的fun方法
Obj2.prototype.fun = function (){Obj2.prototype.constructor.prototype.fun.call(this);}
既然要重写为什么还要调父类的fun呢
function Parent(){}Parent.prototype.say = function(){
alert("a");
}function Child(){}Child.prototype = new Parent();Child.prototype.say = function(){
Child.prototype.constructor.prototype.say.call(this);
alert(1);
}var c = new Child();c.say();</script>
则必定要有 类似 super的字段 不为空则表示超类剩下的就是 你构建的 对象体系的 系统方法(必要方法,比如有没有一个初始化的入口方法)
和 超类对象的允许访问时机
function BaseObj(v1){this.value=v1};function Obj2(v2){this.value="2222222" ,this.oth = v2};BaseObj.prototype.fun = function (){alert(this.value);}Obj2.prototype = new BaseObj();
o2 = new Obj2("22222.value");//o2.fun();Obj2.prototype.fun = function (){Obj2.prototype.constructor.prototype.fun.call(this);alert("没问题啊");} o2.fun();
</script>
this.value=v1
};
BaseObj.prototype.fun = function (){alert(this.value);}function Obj2(v2){
this.value="2222222";
this.oth = v2
};Obj2.prototype = new BaseObj();;
Obj2.prototype.super = BaseObj.prototype;
Obj2.prototype.constructor = Obj2;
Obj2.prototype.fun = function (){
this.super.fun.call(this);
alert(this.oth)
};
o2 = new Obj2("22222.value");
o2.fun();
大侠解释甚好,想问大侠prototype还有什方法和属性没?
想问大侠为什么此句
Obj2.prototype.super = BaseObj.prototype;
之后,就影响了Obj2.prototype的指向为BaseObj。
想问大侠为什么此句
Obj2.prototype.super = BaseObj.prototype;
之后,就影响了Obj2.prototype.constructor的指向为BaseObj。