ExtJS/Sencha Touch中组件的config属性有什么意义?
考虑这样的代码,注意ExtJS/Sencha Touch中组件的config属性有什么意义?,extjs,sencha-touch,Extjs,Sencha Touch,考虑这样的代码,注意config属性 Ext.define('TouchTomatoes.view.WelcomeOverlay', { extend: 'Ext.Panel', xtype: "main", config: { cls: "welcomeOverlay", html: [ "<div class='message'>", "<h2>Welco
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
}
})
}
});
Ext.define('touchtogatos.view.WelcomeOverlay'{
扩展:“Ext.Panel”,
xtype:“main”,
配置:{
cls:“欢迎光临”,
html:[
"",
“欢迎触摸西红柿”,
“通过选择底部的选项卡或在应用程序中滑动浏览我们的任何列表。
您可以在我们的搜索部分找到电影。”,
“点击任意位置开始”,
""
].加入(“”),
隐藏:真的
},
初始化:函数(){
这个元素({
点击:{
fn:函数(){
this.hide();
},
单身:没错,
范围:本
}
})
}
});
到目前为止,我只需将配置项直接放入类定义中,一切都可以正常工作。事实上,我认为这是唯一的方法(因为config
property没有在API中记录)。有人能说出一种方式和另一种方式有何不同吗
同样的事情也适用于initialize
方法,我通常会使用initComponent
来解决这个问题,为什么ExtJS中有这么多可选名称和方法
请务必阅读有关如何处理问题的最新博客文章。应该使用
config
选项为自定义属性创建自己的getter和setter。
假设您在那里添加了另一个属性,如:type:'userform'
。在面板创建过程之后,您可以使用该面板的getType
和setType
方法。在右侧有一个带有复选框的“Show”下拉列表,并为我选中了标签为“Inherited”的下拉列表。我认为,在我这方面,期望列出、继承或拥有所有可用的属性和方法是非常合乎逻辑的。除此之外,这是一个有用的答案。