首页 > 代码库 > extJS 创建类

extJS 创建类

<!DOCTYPE html><html lang="en"><head>    <meta charset="utf-8">    <title>Welcome to Ext JS 5.0</title>    <meta name="description" content="Create amazing web apps built on web standards. Sencha Touch, HTML5 mobile app framework. Ext JS, cross-browser JavaScript framework. Ext GWT" />    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />    <link rel="shortcut icon" type="image/ico" href="http://www.mamicode.com/favicon.ico" />     <!-- 下面的文件都是下载好的extJs包中的 bulid目录下 -->    <!-- 引入必须的css -->    <link rel="stylesheet" href="http://www.mamicode.com/build/packages/ext-theme-crisp/build/resources/ext-theme-crisp-all.css" type="text/css" />          <!-- 引入必须的js -->    <script src="http://www.mamicode.com/build/ext-all.js" type="text/javascript" charset="utf-8"></script>    <script src="http://www.mamicode.com/build/packages/ext-theme-crisp/build/ext-theme-crisp.js" type="text/javascript" charset="utf-8"></script>    </head><body>    <script type="text/javascript">        //在页面加载完成之后执行          //Ext.onReady(function(){          //    Ext.MessageBox.alert(‘hello‘,‘extJs 你好!‘);          //});        /* var win = new Ext.Window(                     {                         width:400,                          height:300,                          title:"hello word",                          buttons:[{text:"确定"},{text:"取消"}],                     }                 );          win.show(); */                  Ext.onReady(function(){                          //定义一个类              Ext.define(‘Person‘,{                  name:‘jaune‘,                  age:18,                  //定义一个方法                  see:function(){ alert(‘我的名字叫‘+this.name); },                  //构造函数                  constructor:function(config){                      //将配置的所有属性都复制到指定的对象                      Ext.apply(this,config);                  }              });                            Ext.define(‘Man‘,{                  extend:‘Person‘,                  sex:‘Male‘,                  constructor:function(config){                      if(config != null){                        if(config.hasOwnProperty(‘sex‘)){                              delete config.sex;                          }                     }                                                                this.callParent([config]);                  },                  toString:function(){                      return {                          name:this.name,                          age:this.age,                          sex:this.sex                      }                  }              });                            var man = new Man({                name:‘zh‘,                age:12,                sex:‘man‘            });              alert(man.toString().sex);         });    </script></body></html>

 

  

extJS 创建类