Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript ol外部控制栏和控制器中的功能_Javascript_Extjs_Sencha Touch_Openlayers - Fatal编程技术网

Javascript ol外部控制栏和控制器中的功能

Javascript ol外部控制栏和控制器中的功能,javascript,extjs,sencha-touch,openlayers,Javascript,Extjs,Sencha Touch,Openlayers,我有一个extjs应用程序,其中我使用的是ol ext控制栏。控制栏在文件MyApp.js中,我想要调用的函数单击属于控制栏的按钮位于相对控制器MyAppController中。 在MyApp.js中: var testFuction=function(){ 返回此.getController().updateImages; }; var mainbar=new ol.control.Bar(); var first=新建ol.control.Button( { html:'1', //处理程

我有一个extjs应用程序,其中我使用的是ol ext控制栏。控制栏在文件MyApp.js中,我想要调用的函数单击属于控制栏的按钮位于相对控制器MyAppController中。 在MyApp.js中:

var testFuction=function(){
返回此.getController().updateImages;
};
var mainbar=new ol.control.Bar();
var first=新建ol.control.Button(
{
html:'1',
//处理程序:“updateImages”,
//参考:“locationShowImageButton”,
handleClick:TestFunction,
});
//标准控制
mainbar.addControl(第一个);
mainbar.setPosition(“右下”);

this.map.addControl(主工具栏)
首先检查
MyApp.js中的
this.getController()
是否参见
MyAppController

不能像sencha组件那样使用
ol.control.Button

您应该在您的
MyApp.js
范围中使用
this

var mainbar = new ol.control.Bar();
var me = this;
var first = new ol.control.Button (
 {
        html: '1',
        handleClick: function () {
            me.getController().updateImages();
        }
 });

//Standard Controls
mainbar.addControl (first);
mainbar.setPosition('bottom-right');
this.map.addControl(mainbar);

是否可以附加发生的异常/错误?是否调用了函数
updateImages
?是的,我有一个错误:
Uncaught TypeError:this.getController不是一个函数
,它就像一个无法与控制器的函数通信并使控制器的函数知道我按下了控制栏的按钮。
MyAppController
它是一个ViewController?也许您应该在
第一个按钮中使用
handleClick:'updateImages'
而不是
handleClick:testFunction
。是的。我试过了,它给了我错误
options.handleClick.call不是一个函数