//creating the main Object variables with static Propertys
var MySystem={
Utility:{},
AppDbSystem:{
connecterObj:"",
objCollection:new Array(),
sendObjCollection:null,
phpGridCollection:null
},
OutManager:{},
DbIndex:{},
GoDb:{},
Ioform:{},
ListView:{},
WindowSystem:{},
AngularSystem:{
objCollection:null
}
}
//the parent class (top of the chain)
MySystem.GoDb.GoDb=function(){
var that=this;
this.namespace;
this.speicher;
this.initGoDb=function(table,group,indexArr,readOnly){
that.speicher=table;
}
this.showS=function(){
alert(that.speicher);
}
this.setNamespace=function(ns){
that.namespace=ns;
}
this.getNamespace=function(){
return that.namespace;
}
}
//ListView second Class of the Chain
MySystem.ListView.ListView=function(){
var that=this;
MySystem.GoDb.GoDb.apply(this); //IMPORTANT to make it as an Instance
this.initListView=function(submitIndex,idArr,methodActionArr){
that.initGoDb(submitIndex);
}
}
MySystem.ListView.ListView.prototype=new MySystem.GoDb.GoDb();
//The Child Class
MySystem.ListView.ListStandard=function(){
var that=this;
MySystem.ListView.ListView.apply(this);
this.init=function(elementYArr,attrs,methodActionArr,idArr,tableId,styleArr,styleArrTr,styleArrTd,withNumbers,submitIndex){
that.initListView(elementYArr);
}
}
MySystem.ListView.ListStandard.prototype=new MySystem.ListView.ListView();
//now use it
var test=new MySystem.ListView.ListStandard();
var test2=new MySystem.ListView.ListStandard();
test.init("eazy");
test.showS();
test2.init("second obj");
test2.showS();
test.showS();
看http://www.zipcon.net/~swhite/docs/computers/languages/object_oriented_JS/inheritance.html
不要忘记做套用来电。
MySystem.ListView.ListView.apply(this);
否则对象属性是静态的,不可继承。
适用于我,控制台上没有'undefined'。但是,如果你想计算和打印该区域,你需要实际调用该函数,如下所示:'console.log(circle.Area());' – cyroxx 2013-04-21 19:23:19
你想*调用*'区域',其中大小写,使用'Area()'? – 2013-04-21 19:23:20
你从哪里得到'undefined'的小提琴?我得到一个对象,一个字符串和一个函数。 – Bergi 2013-04-21 19:23:41