我有一个带有区域的互联网应用程序 mvc4,对于我的组织来说,每个区域代表一个 SPA,通过“管理 NuGet 包”我安装了“Durandal 1.2.0”、“Durandal Transitions 1.2.0”和“Durandal Router 1.2.0”。我组织了文件夹并从 Durandal 的文件夹“App”中退出“views”和“viewmodels”,并将新视图放入 mvc4 区域的文件夹“VIews”中,例如:
区域-->新建区域-->视图-->ControllerFolder-->视图-->shell.html
然后我将“viewmodels”放入“Script”文件夹中,例如:
脚本-->NewArea-->ControllerFolder-->viewmodels-->shell.js
脚本-->NewArea-->ControllerFolder-->main.js
然后我更改了 durandal JS 的路径,例如在 main.js 中:
define(['../../../App/durandal/app',
'../../../App/durandal/viewLocator',
'../../../App/durandal/system',
'../../../App/durandal/plugins/router',
'../../../App/services/logger'],
我在下一行更改了 main.js:
viewLocator.useConvention('viewmodels', '../Areas/NewArea/Views/ControllerFolder/views');
但是文件夹的配置失败,因为下一行在其定义中多次调用模块“viewLocator”,并使用默认值重写“useConvention”的配置:
app.setRoot('viewmodels/shell', 'entrance');
仅当文件夹“views”和“viewmodels”不在“Durandal”的“App”文件夹下时,才会发生这种行为。
请帮我,如何在同一个项目中拥有多个 SPA?