`
standalone
  • 浏览: 598176 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

extjs mixin example

阅读更多
//1. Define our simple mixin class called HasCamera with a single //method called takePhoto:
Ext.define('HasCamera', {
takePhoto: function(){
alert('Say Cheese! .... Click!');
}
});
//2. Define a skeleton class and use the mixins configuration option //to apply our HasCamera mixin to our Cookbook.Smartphone class.
Ext.define('Cookbook.Smartphone', {
mixins: {
camera: 'HasCamera'
}
});
//3. We can now call our mixin's takePhoto method as part of the 
// Smartphone's class within a useCamera method:
Ext.define('Cookbook.Smartphone', {
mixins: {
camera: 'HasCamera'
},
useCamera: function(){
this.takePhoto();
}
});
//4. Instantiate the Smartphone class and call the useCamera method:
var smartphone = Ext.create('Cookbook.Smartphone');
smartphone.useCamera(); // alerts 'Say Cheese! .... Click!'
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics