我在视图的初始化部分声明了一个变量。当我尝试在面板中声明的函数中访问此变量时,我收到一个错误,指出该变量未定义。我尝试通过 1>this.variablename 访问它2>viewid.variablename....我做错了什么?
Ext.define('app.view.location', {
extend : 'Ext.Panel',
xtype : 'location_d',
id : 'locdetail',
initialize : function() {
loc = 'abc';
},
config : {
layout : {
type : 'card'
},
scrollable : true,
fullscreen : true,
items : [{
xtype : 'panel',
html : 'Get Dir',
id : 'Dir',
cls : 'loc',
listeners : {
tap : {
element : 'element',
fn : function(m) {
alert(this.loc); //gives me undefined variable error
}
}
}
}]
}
});