BackboneJS vs JavaScriptMVC vs KnockoutJS
我想为复杂的 Web 应用程序使用 JavaScript 框架。我一直在研究 Backbone.js、knockout.js 和 JavaScriptMVC。作为客户端 JavaScript 重型网络应用程序的新手,我不确定该选择哪一个。每个人都有一种截然不同的方法来区分问题。模型/视图/控制器与模型/视图/视图模型与模型/视图/集合。
你们觉得怎么样?决定因素是什么?哪一个最容易拿起?你的经历是怎样的?
I want to use a JavaScript framework for a complex web application. I have been looking at Backbone.js, knockout.js and JavaScriptMVC. Being pretty new to client side JavaScript heavy web apps, I'm not sure which one to pick. Each one has a pretty different approach to separate the concerns. Model/View/Controller vs Model/View/ViewModel vs Model/View/Collection.
What do you guys think? What are the deciding factors? Which one would be the easiest to pick up? What has your experience been like?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
无论哪种方式都不会出错,尤其是在构建复杂的 javascript UI 时。如果您选择不使用其中任何一个,您可能会得到许多难以调试的代码。我个人喜欢 Backbone,但它们都是轻量级的,并且允许您自由地使用模板语言(我使用 JQuery 模板)。我认为让我选择 Backbone 的原因是 Knockout 将其组件与您的 html 混合的方式:
您也许可以避免在 Knockout 中使用上述结构,但这足以让我转向 Backbone。我还喜欢这样一个事实:backbone 依赖于 underscore 和 jquery,它们已经在我的项目中使用了。
You can't go wrong either way especially if you are building a complex javascript UI. If you choose not to use either, you will likely wind up with a lot of difficult to debug code. I personally like Backbone but they are both lightweight and allow you freedom in your templating language (I use JQuery templates). I think what made me choose Backbone was the way Knockout mixed its components in with your html:
You may be able to avoid using constructs like the above with Knockout but that was enough to throw me toward Backbone. I also liked the fact that backbone has dependencies on both underscore and jquery which were already in use in my projects.
以 HostDude 的评论为基础 - 这是一个功能,而不是一个错误:) 淘汰概念的一部分是在你的控制器/模型和视图之间有一个层。这让我们可以将 HTML 模块化为包含数据映射的小组件。
所以,是的,JS 绑定被混合在一起,但它们没有混合到原始 HTML 中 - 而是添加到微小的模块化 Jquery 模板中。通过在 jQuery 模板级别显式添加这些数据绑定,我们可以完全控制映射到什么的内容 — 根本不会干扰我们的底层应用程序数据模型:) 我喜欢 Knockout!
To build on HostDude's comment - it's a feature, not a bug :) Part of the concept of knockout is that there's a layer inbetween your Controller/Model and the View. This lets us modularize our HTML into small components that include the data mapping.
So yes the JS bindings are mixed in, but they are not mixed into raw HTML - rather they are added to tiny modularized Jquery templates. By adding those data bindings in explicitly at the jQuery template level, we have total control over what's mapped to what -- without disturbing our underlying application data model at all :) I love Knockout!