Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.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
Knockout.js 单文件SPA中的多模块_Knockout.js_Module_Durandal_Single Page Application - Fatal编程技术网

Knockout.js 单文件SPA中的多模块

Knockout.js 单文件SPA中的多模块,knockout.js,module,durandal,single-page-application,Knockout.js,Module,Durandal,Single Page Application,我有点小要求。我刚开始做简单的SPA应用程序。我的要求是在.js文件中编写类,并且我应该能够在另一个.js文件中调用单个类 *globals define*/ define(function(require){ ... return search; }); define(function(require){ ... return order; }); define(function(require){ ... return cust

我有点小要求。我刚开始做简单的SPA应用程序。我的要求是在.js文件中编写类,并且我应该能够在另一个.js文件中调用单个类

*globals define*/
define(function(require){
   ...

      return search;
}); 
define(function(require){
   ...

      return order;
}); 
define(function(require){
   ...

      return customer;
}); 
简而言之,我在一个.js文件中有Search、Order和Customer类

*globals define*/
define(function(require){
   ...

      return search;
}); 
define(function(require){
   ...

      return order;
}); 
define(function(require){
   ...

      return customer;
}); 
我想把任何一个都称为上面的模块。有什么解决办法吗


谢谢,
湿婆

这种方式是不允许的。这个问题还有其他解决办法

Durandal中的模块由AMD库处理。图书馆的文件中说:

每个文件一个模块。:每个JavaScript只能定义一个模块 文件,给定模块名的性质以进行文件路径查找 算法。多个模块将按以下方式分组到优化文件中: 优化工具,但您应该只使用优化工具 在文件中放置多个模块

如上所述,一个选项是将多个模块(多个文件)优化为一个文件。()

或者,您可以定义一个模块,其中包含多个对象,如本文所述。使用这种方法,您将无法单独加载对象,因此始终需要加载
search、order
customer
对象,即使您只需要一个