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