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
Function 如何在Sencha Architect中创建函数?_Function_Extjs_Sencha Architect - Fatal编程技术网

Function 如何在Sencha Architect中创建函数?

Function 如何在Sencha Architect中创建函数?,function,extjs,sencha-architect,Function,Extjs,Sencha Architect,我正在跟踪,有一个关于函数的问题。我发现我们可以在passFn和failFn区域中嵌入函数。但是,如果我希望这些函数位于其他位置,该怎么办?在何处创建这些函数并在Sencha Architect中编码?以下是如何在Architect中使用基本函数: 创建一个控制器 添加控制器动作并按如下方式设置其属性: Ext.Ajax.request({ url: 'foo.php', // where you wanna post success: passFn, // functio

我正在跟踪,有一个关于函数的问题。我发现我们可以在passFn和failFn区域中嵌入函数。但是,如果我希望这些函数位于其他位置,该怎么办?在何处创建这些函数并在Sencha Architect中编码?

以下是如何在Architect中使用基本函数:

  • 创建一个控制器

  • 添加控制器动作并按如下方式设置其属性:

    Ext.Ajax.request({
       url: 'foo.php',    // where you wanna post
       success: passFn,   // function called on success
       failure: failFn,
       params: { foo: 'bar' }  // your json data
    });
    
  • 添加基本函数并设置其属性:

    controlQuery: '#btn1', // (a button component with id "btn1")
    targetType  : Ext.Button, // (component type)
    fn          : onBtn1Tap, // (function name)
    name        : tap // (event)
    
  • 现在您可以在onBtn1Tap中使用此基本函数:
    this.basicFunction()


  • 您可以创建Sencha Architect控件之外的文件夹,并从Architect代码内部调用它

    例如,我喜欢创建一个名为“util”的文件夹。下面是您的文件夹结构的外观:

    fn: basicFunction  (function name)
    
    然后,您可以从架构师代码中引用这些函数:

    Ext.define('MyApp.util.MiscFunctions', {
       singleton: true,
       passFn: function() {
          ...
       },
       failFn: function() {
       }
    });
    
    别忘了添加

    Ext.Ajax.request({
       url: 'foo.php',    // where you wanna post
       success: MyApp.util.MiscFunctions.passFn,   // function called on success
       failure: MyApp.util.MiscFunctions.failFn,
       params: { foo: 'bar' }  // your json data
    });
    
    部分,否则必须创建该类的实例才能使用其中的函数

    Ext.Ajax.request({
       url: 'foo.php',    // where you wanna post
       success: MyApp.util.MiscFunctions.passFn,   // function called on success
       failure: MyApp.util.MiscFunctions.failFn,
       params: { foo: 'bar' }  // your json data
    });
    
    singleton: true