这是我的看法
Ext.define('ValidationErrorView', {
extend : 'Ext.panel.Panel',
alias : 'widget.validationErrorView',
layout : 'fit',
overflow : 'auto',
autoScroll : true,
xTitle : 'Title',
XFun :function(name){
return "Hello " + name;
}
border : false,
initComponent : function() {
var tpl = new Ext.XTemplate(
'<tpl for=".">',
'<div>{xTitle}',
'<p>{[xFun(name)]}',
'</div>',
'</tpl>'
);
}
});
我想在我的模板中使用 xTitle 和 xFun()。我正在使用 {[..]} 来调用我的函数,但这不起作用?如何在模板中同时使用 xTitle 和 XFun()?
最佳答案
按以下格式调用函数:
initComponent : function() {
var tpl = new Ext.XTemplate(
'<tpl for=".">',
'<div>{xTitle}',
'<p>{[this.xFun(name)]}',
'</div>',
'</tpl>',
{
XFun :function(name){
return "Hello " + name;
}
}
);
}
这肯定会起作用。我已经删除了您在 initComponent() 之外的函数 Xfun。
关于javascript - 如何在 XTemplate extjs 4 中调用函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41690388/