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="/favicon.ico" />
     <!-- 下面的文件都是下载好的extJs包中的 bulid目录下 -->
    <!-- 引入必须的css -->
    <link rel="stylesheet" href="build/packages/ext-theme-crisp/build/resources/ext-theme-crisp-all.css" type="text/css" />
   
       <!-- 引入必须的js -->
    <script src="build/ext-all.js" type="text/javascript" charset="utf-8"></script>
    <script src="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>

 

  

转载于:https://www.cnblogs.com/shaoshao/p/4103949.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值