Model view controller 如何使用Sencha Touch 2在“initialize”方法中调用“refs”组件?

Model view controller 如何使用Sencha Touch 2在“initialize”方法中调用“refs”组件?,model-view-controller,controller,initialization,sencha-touch-2,refs,Model View Controller,Controller,Initialization,Sencha Touch 2,Refs,我想通过使用senchatouch2的MVC模式在图像中滑动来更改xtype:'label'的Html输出 滑动事件工作正常,即它在控制台上显示“左”和“右”输出,但由于某种原因,this.getOrientationLabel().getHtml()未被调用 MyView.js MyController.js Ext.define('stromtechner.controller.Settings'{ 扩展:“Ext.app.Controller”, 配置:{ 参考文献:{ houseImag

我想通过使用senchatouch2的MVC模式在图像中滑动来更改
xtype:'label'
的Html输出

滑动事件工作正常,即它在控制台上显示“左”和“右”输出,但由于某种原因,
this.getOrientationLabel().getHtml()
未被调用

MyView.js MyController.js
Ext.define('stromtechner.controller.Settings'{
扩展:“Ext.app.Controller”,
配置:{
参考文献:{
houseImage:“图像”,
方向标签:“#方向标签”
},
控制:{
“房屋形象”:{
初始化:“initImage”
}
}
},
initImage:function(image){
image.element.on({
滑动:功能(e、节点、选项){
如果(如方向=“左”){
控制台日志(“左”);
}否则,如果(如方向=“右”){
控制台日志(“右”);
}

console.log(this.getOrientionLabel().getHtml());//您需要为事件侦听器指定适当的作用域,或者在闭包外部指定一个变量,然后在闭包内访问该变量

备选案文1:

initImage: function(image){
    image.element.on('swipe', function(e, node, options){
        if (e.direction == "left"){
            console.log("LEFT");
        }else if (e.direction == "right"){
            console.log("RIGHT");
        }
        console.log( this.getOrientationLabel().getHtml() ); 
    }, this);
}
备选案文2:

initImage: function(image){
    var me = this;
    image.element.on('swipe', function(e, node, options){
        if (e.direction == "left"){
            console.log("LEFT");
        }else if (e.direction == "right"){
            console.log("RIGHT");
        }
        console.log( me.getOrientationLabel().getHtml() ); 
    });
}
initImage: function(image){
    image.element.on('swipe', function(e, node, options){
        if (e.direction == "left"){
            console.log("LEFT");
        }else if (e.direction == "right"){
            console.log("RIGHT");
        }
        console.log( this.getOrientationLabel().getHtml() ); 
    }, this);
}
initImage: function(image){
    var me = this;
    image.element.on('swipe', function(e, node, options){
        if (e.direction == "left"){
            console.log("LEFT");
        }else if (e.direction == "right"){
            console.log("RIGHT");
        }
        console.log( me.getOrientationLabel().getHtml() ); 
    });
}