有没有淘汰赛页面/路由框架? [英] Are there any knockoutjs page/routing frameworks?

查看:18
本文介绍了有没有淘汰赛页面/路由框架?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

来自 asp.net MVC 3.在 MVC4 中,他们引入了 WebAPI.能够在 javascript 中完成所有视图/路由代码并且只依赖 MVC 的 API 会很好.webapi 可以独立于 IIS 运行真是太酷了!

话虽如此:

是否有任何页面框架可以利用类似于我下面的模型的 KnockoutJS:

Framework.RegisterRoutes(..,mainViewModel);//设置CurrentViewModel?

每个路由都是一个单独的viewModel文件,一个视图被注入到主视图中

var mainviewModel= function(){var self = this;self.CurrentViewModel = ko.observable();...回归自我;}<div id="mainPageContent" data-bind:'html:CurrentViewModel.Render'>

我知道很多可以自己实现,但不确定如何实现注册路由/加载单独的文件

我觉得knockoutjs的主要优点是能够不干扰你编写js的方式(即,只要交互对象是可观察的,就可以按照你想要的方式构建对象/框架)

解决方案

Pager.js 是专为与 Knockout 配合使用而构建的 URL 路由框架.js.确保您通读了整个演示以了解其全部功能和灵活性.恕我直言,它远远超过 PathJS 和 Sammy.

Coming from asp.net MVC 3. In MVC4 they introduced WebAPI's. It would be nice to be able to do all view/routes code in javascript and just rely on MVC for API. Heck it's really cool that webapi's can be run independent of IIS!

That being said:

Are there any page frameworks that can leverage KnockoutJS which are similar to my mock-up below:

Framework.RegisterRoutes(..,mainViewModel);//sets the CurrentViewModel?

Each route being a separate file of a viewModel, and a view to be injected into the master view

var mainviewModel= function(){
   var self = this;
   self.CurrentViewModel = ko.observable();
   ...
   return self;
}

<div id="mainPageContent" data-bind:'html:CurrentViewModel.Render'>
</div>

I know that a lot of this can be achieved by self, but not sure how to achieve the register routes/ loading separate files

I feel like knockoutjs's main strengths is the ability to not intrude into the way you code js (ie build an object/framework how you want so long as the interacting objects are observable)

解决方案

Pager.js is a URL routing framework built specifically for use with Knockout.js. Make sure you go through the entire Demo to see its full power and flexibility. IMHO, it far exceeds PathJS and Sammy.

这篇关于有没有淘汰赛页面/路由框架?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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