2016-10-03 59 views
0

只想获得tpl文本显示,即使组件呈现成功但内部没有文本。看起来屏幕上空白ExtJs Tpl没有显示

Ext.Component({ 
    ... 
    tpl: 'Hi let me show on screen please', 
}); 

为什么没有显示任何东西?

回答

2

模板预期要定义的data属性:

var foo = new Ext.Component({ 
    renderTo: document.body, 
    tpl: 'foo baroo', 
    data: {} 
}); 
+0

感谢的人!你用这样一种精确的方式来描述它 –

1

作为每Documentation

的数据配置必须的任何内容被设定使用此配置,当在部件上显示。

根据你的代码,你没有绑定数据,并没有得到结果。

示例代码应该是这样的:

Ext.Component({ 
renderTo: Ext.getBody(), 
tpl: ['<ul class="details">', 
     '<li><b>Name:</b> {Name}</li>', 
     '<li><b>Email:</b> {Email}</li>', 
    '</ul>'], 
data: { 
    Name: 'User-1', 
    Email: '[email protected]' 
} 
});