考虑这样的代码并注意该config
属性。
Ext.define('TouchTomatoes.view.WelcomeOverlay', {
extend: 'Ext.Panel',
xtype: "main",
config: {
cls: "welcomeOverlay",
html: [
"<div class='message'>",
"<h2>Welcome to <em>Touch Tomatoes</em></h2>",
"<p>Browse any of our lists by selecting a tab at the bottom, or swiping across the app. <br/>You can find a movie in our search section.</p>",
"<div class='tap'>Tap anywhere to begin</div>",
"</div>"
].join(""),
hidden:true
},
initialize: function() {
this.element.on({
tap: {
fn: function() {
this.hide();
},
single:true,
scope:this
}
})
}
});
到现在为止,我只是将配置项直接放入类定义中,并且一切正常。实际上,我在想这是唯一的方法(例如,因为config
属性未在API中记录)。谁能说出一种方法与另一种方法有何不同?
同样的事情也适用于initialize
方法有,我通常会用initComponent
这个,为什么在ExtJS的这么多的替代名称和方式?
该config
选项应用于为您的自定义属性创建自己的getter和setter。假设您在此处添加了另一个属性,例如:type: 'userform'
。面板创建过程完成后,您将可以使用getType
和setType
方法用于该面板。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句