classes system in sencha touch

//http://www.sencha.com/learn/sencha-class-system
var Person = new Ext.Class({
    name: 'Mr. Unknown',
    walk: function(steps) {
        alert(this.name + ' is walking ' + steps + ' steps');
    }
});


//http://docs.sencha.com/touch/2.2.1/#!/guide/class_system
//Ext.ns('My.sample');//define the namespace
Ext.define('Animal', {

    requires: [
        'Ext.MessageBox'
    ],
    
    constructor: function(config) {
        this.initConfig(config);
    },
    
    config: {
        name: 'default name',
        gender:'male'
    },

    
    speak: function() {
        //alert('grunt');
        Ext.Msg.alert(this.getName(), "Speaks...");
    },
    
    statics : {
        
       static1  :function(){    
            console.log('static fun1, called by Animail.static1');
        }
    } 
});

console.log('launching...');
Animal.static1();
var ani=Ext.create('Animal',{name:'abc'});
console.log(ani.getName());
ani._name='zhaoyao';
console.log(ani.getName());
console.log(ani._gender);
ani.speak();
原文地址:https://www.cnblogs.com/zyip/p/3531862.html