Durandaljs可以做区域吗 [英] Can Durandaljs do Areas

查看:50
本文介绍了Durandaljs可以做区域吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试是否有办法在Durandaljs中做区域

I'm trying to see if there is a way to do areas in Durandaljs

类似

/App/areas/home
                /views
                /viewmodels
          /other
                /views
                /viewmodels

我看到viewLocator允许以下约定:

I see the viewLocator allowing this convention:

 viewLocator.useConvention('viewmodels', 'views', 'areas');

但是router.useConvention()似乎默认为同一路径。

but the router.useConvention() seems to default to same path.

是否有适当的方法来解决这个问题,在这方面的文档很浅。

Is there a proper way to account for this, the documentation is light in this regard.

推荐答案

是的,您可以这样做。

由于使用的是Durandal.router,因此可以通过覆盖路由器autoConvertRouteToModuleId来使用约定在何处查找ViewModels: p>

Since you are using Durandal.router you can use a convention of where to find your ViewModels by overriding the routers autoConvertRouteToModuleId like so:

router.autoConvertRouteToModuleId = function(url, params) {
    return url + '/' + 'params[0]';
};

至于找到绑定到视图模型的视图,就像上面一样。 viewlocator约定。

As for finding the view that binds to your viewmodel then you can like you have above.. change the viewlocator convention.

这篇关于Durandaljs可以做区域吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆