0
为什么下面的代码不工作(ExtJS V6)?访问类中的私有属性
Ext.define('Test', {
extend: 'Ext.window.Window',
xtype: 'basic-window',
config: {
mytitle: ''
},
constructor: function (config) {
Ext.apply(this, config);
this.callParent(config);
},
requires: [
'Ext.form.Panel'
],
height: 300,
width: 400,
scope: this,
title: 'title: ' + this.mytitle,
autoScroll: true,
autoShow: true,
bodyPadding: 10,
html: "Lorem ipsum",
constrain: true,
});
var t = Ext.create('Test', {mytitle: 'testtitle'});
t.show();
我认为这会将窗口的标题设置为“title:testtitle”。相反,它将标题设置为“title:undefined”。
附加:如果我使用
...
title: 'title' + this.getMytitle(),
...
我得到 “遗漏的类型错误:this.getMytitle不是一个函数”。为什么?
在这里你可以找到更多有关神奇的getters,setters,更新和应用函数的信息:https://www.sencha.com/forum/showthread.php?171113-Difference-between-update-and- apply-magic-methods&p = 708489&viewfull = 1#post708489 – Tarabass
@juan非常感谢!优秀的答案... – itsame69