单页 JavaScript Web 应用程序的架构? [英] Architecture of a single-page JavaScript web application?

查看:36
本文介绍了单页 JavaScript Web 应用程序的架构?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个复杂的单页 JS Web 应用程序应该如何在客户端构建?具体来说,我很好奇如何根据模型对象、UI 组件、任何控制器和处理服务器持久性的对象来清晰地构建应用程序.

How should a complex single-page JS web application be structured on the client-side? Specifically I'm curious about how to cleanly structure the application in terms of its model objects, UI components, any controllers, and objects handling server persistence.

MVC 起初似乎很合适.但是随着 UI 组件嵌套在不同的深度(每个都有自己的方式对模型数据进行操作/反应,并且每个生成的事件它们自己可能会或可能不会直接处理),看起来 MVC 似乎不能干净地应用.(但如果不是这样,请纠正我.)

MVC seemed like a fit at first. But with UI components nested at various depths (each with their own way of acting on/reacting to model data, and each generating events which they themselves may or may not handle directly), it doesn't seem like MVC can be cleanly applied. (But please correct me if that's not the case.)

--

(这个问题导致了两个使用ajax的建议,除了最微不足道的单页应用程序之外,这显然是其他任何东西所需要的.)

(This question resulted in two suggestions of using ajax, which is obviously needed for anything other than the most trivial one-page app.)

推荐答案

PureMVC/JS 是最优雅的 IMO.我从中学到了很多.我还发现 Nicholas Zakas 的 可扩展 JavaScript 应用程序架构有助于研究客户端架构选项.

MVC architecture of PureMVC/JS is the most elegant IMO. I learned a lot from it. I also found Scalable JavaScript Application Architecture by Nicholas Zakas helpful in researching client side architecture options.

另外两个提示

  1. 我发现视图、焦点和输入管理是单页 Web 应用程序中需要特别注意的领域
  2. 我还发现将 JS 库抽象出来很有帮助,为改变您使用的内容或混合& 的内容敞开大门.需要时匹配.

这篇关于单页 JavaScript Web 应用程序的架构?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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