BackboneJS vs JavaScriptMVC vs KnockoutJS

发布于 2024-10-19 19:08:20 字数 219 浏览 2 评论 0原文

我想为复杂的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

指尖微凉心微凉 2024-10-26 19:08:20

无论哪种方式都不会出错,尤其是在构建复杂的 javascript UI 时。如果您选择不使用其中任何一个,您可能会得到许多难以调试的代码。我个人喜欢 Backbone,但它们都是轻量级的,并且允许您自由地使用模板语言(我使用 JQuery 模板)。我认为让我选择 Backbone 的原因是 Knockout 将其组件与您的 html 混合的方式:

<span data-bind="text: myItems().count"></span>

您也许可以避免在 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:

<span data-bind="text: myItems().count"></span>

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.

吃→可爱长大的 2024-10-26 19:08:20

以 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!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文