首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Ajax >

Extjs类的动态加载时碰到有关问题求解

2013-01-07 
Extjs类的动态加载时碰到问题求解我在学习Extjs类的动态加载时,碰到一个问题,求解啊问题如下:在webroot/sr

Extjs类的动态加载时碰到问题求解
我在学习Extjs类的动态加载时,碰到一个问题,求解啊
问题如下:在webroot/src/Cookbook文件夹中有两个类Vehicle和Plane
Vehicle.js代码如下:
Ext.define('Cookbook.Vehicle', {
                                                config : {
                                                        manufacturer : 'UnKown Manufacturer',
                                                        model : 'UnKown Model',
                                                        topSpeed : 0
                                                },

                                                constructor : function(manufacturer, model, topSpeed) {
                                                        this.initConfig();
                                                        if (manufacturer)
                                                                this.setManufacturer(manufacturer);
                                                        if (model)
                                                                this.setModel(model);


                                                        if (topSpeed)
                                                                this.setTopSpeed(topSpeed);
                                                },

                                                travel : function(distance) {
                                                        alert("the" + this.getManufacturer() + " "
                                                                        + this.getModel() + "travel" + " " + distance
                                                                        + "miles at a topSpeed of" + this.getTopSpeed()
                                                                        + "  mph");
                                                }

                                        }, function() {
                                                alert("Cookbook.Vehicle class is created");


                                        });

plane.js代码如下:
Ext.define('Cookbook.Plane',{
                                                extend: 'Cookbook.Vehicle',
                                                       config:{
                                                   maxAltitude:0
                                                       
                                               },
                                               constructor:function(manufacturer,model,topSpeed,maxAltitude){
                                                       this.initConfig();
                                                       if(maxAltitude)
                                                        this.setMaxAltitude(maxAltitude);
                                                        
                                                        this.callParent([manufacturer,model,topSpeed]);


                                                       
                                               },
                                               showMaxAltitude: function(){
                                                                alert("the plane"+this.getManufacturer()+" "+this.getModel()+" maxAltitude is "+plane.getMaxAltitude()+"miles");
                                               },
                                               takeOff:function(){
                                                           alert("the plane"+this.getManufacturer()+" "+this.getModel()+"is takeOff");
                                               },
                                               land:function(){
                                                           alert("the plane"+this.getManufacturer()+" "+this.getModel()+"is landing");
                                               },
                                               travel:function(distance){


                                                          this.takeOff();
                                                          this.callParent(arguments);
                                                          this.showMaxAltitude();
                                                          this.land();
                                               }
                                        },function(){
                                                   alert("Cookbook.Plane class is created");
                                                }
                                        );

在app.js中动态的加载plane这个类
Ext.onReady(function (){
      Ext.Loader.setConfig(
      {
        enabled:true,
        paths:{
                'Cookbook' :"src/Cookbook"
        }
      });

      Ext.require('Cookbook.Plane',function(){
       var plane= Ext.create('Cookbook.Plane','Boeing','747','1200','10000');
       plane.travel(10000);
      });

}
);


在app.js中plane这个对象的travel()方法执行出现问题,只执行了travel方法中的  this.takeOff();和   this.callParent(arguments);两个方法,而   this.showMaxAltitude();和this.land();这两个方法并没有并执行,显示的错误是:Uncaught ReferenceError: plane is not defined 。搞不明白为什么会出这种问题,求助。


[解决办法]
alert("the plane"+this.getManufacturer()+" "+this.getModel()+" maxAltitude is "+plane.getMaxAltitude()+"miles");

plane变量没定义,不是说了。。getMaxAltitude方法也没定义

热点排行