问题
I'm trying to see if there is a way to do areas in Durandaljs
Something along the lines of
/App/areas/home
/views
/viewmodels
/other
/views
/viewmodels
I see the viewLocator allowing this convention:
viewLocator.useConvention('viewmodels', 'views', 'areas');
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.
回答1:
yes you can do this.
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]';
};
As for finding the view that binds to your viewmodel then you can like you have above.. change the viewlocator convention.
来源:https://stackoverflow.com/questions/15416494/can-durandaljs-do-areas