Tuesday, 15 April 2014

extjs4.2 - Extend's Constructor can't find config parm? -



extjs4.2 - Extend's Constructor can't find config parm? -

in extjs4.2;

in follow code,it's show "uncaught referenceerror: config not defined " on chrome's console.

that maybe problem in vehicle.prototype.constructor.call(this,config); but, why can't pass config.

why? can help me ?

thank .

function vehicle(config){ this.x=config.x; this.y=config.y; } vehicle.prototype.move=function(dx,dy){ this.x +=dx; this.y +=dy; }; vehicle.prototype.tostring=function(){ homecoming "point:"+x+","+y; }; var car=ext.extend(vehicle,{ constructor:function(){ vehicle.prototype.constructor.call(this,config); this.color=config.color; },move:function(dx){ this.x=dx; },tostring:function(){ var str="car "+ this.x + " miles away origial position."; str +=" auto :"+this.colr; homecoming str; } }); var carconfig={ x:10, y:0, color:"white" }; var car= new car(carconfig); car.move(150); console.info(car.tostring());

all missing parameter constructor function.

i made fiddle show ya: http://jsfiddle.net/edhedges/jkpll/

function vehicle(config){ this.x=config.x; this.y=config.y; } vehicle.prototype.move=function(dx,dy){ this.x +=dx; this.y +=dy; }; vehicle.prototype.tostring=function(){ homecoming "point:"+x+","+y; }; var car=ext.extend(vehicle,{ constructor:function(config){ // missing config here vehicle.prototype.constructor.call(this,config); this.color=config.color; },move:function(dx){ this.x=dx; },tostring:function(){ var str="car "+ this.x + " miles away origial position."; str +=" auto :"+this.colr; homecoming str; } }); var carconfig={ x:10, y:0, color:"white" }; var car= new car(carconfig); car.move(150); console.info(car.tostring());

extjs4.2

No comments:

Post a Comment