你能解释一下我必须使用这个吗?我有一个这样的例子,但我想为什么我们只需在h1标签中设置.css ID或CLASS?为什么我们需要这个孩子们??而当我使用相同的技术为msg它不工作为什么?为什么我们需要在extjs中使用childEls - 在哪里使用?
1)我们为什么要使用这个配置? 2)使用地点? 3)我们不能定义.css类或id和样式吗? 4)当我对msg使用相同的技术时,它不起作用。
Ext.onReady(function() {
// Explicitly create a Container
Ext.create('Ext.Component', {
renderTo: Ext.getBody(),
renderTpl: [
'<h1 id="{id}-title" data-ref="title">{title}</h1>',
'<p>{msg}</p>',
],
renderData: {
title: "Error",
msg: "Something went wrong"
},
childEls: ["title"],
listeners: {
afterrender: function(cmp){
console.log(cmp);
// After rendering the component will have a title property
cmp.title.setStyle({color: "red"});
}
}
});
});
对于我使用此代码的mes。
Ext.onReady(function() {
// Explicitly create a Container
Ext.create('Ext.Component', {
renderTo: Ext.getBody(),
renderTpl: [
'<h1 id="{id}-title" data-ref="title">{title}</h1>',
'<p id="{id}-msg" data-ref="msg">{msg}</p>',
],
renderData: {
title: "Error",
msg: "Something went wrong"
},
childEls: ["title","msg"],
listeners: {
afterrender: function(cmp){
console.log(cmp);
// After rendering the component will have a title property
cmp.title.setStyle({color: "red"});
cmp.msg.setStyle({color: "green"});
}
}
});
});
谢谢!
OMG现在正在工作。没有改变。正如你所说,它应该工作,现在工作。不知道发生了什么。无论如何thx为您的解释。 – Justin 2014-10-17 08:59:49