Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 10 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(1)
我没有使用任何特定的框架,但我开发了一个基于 MVC 的生产 Web 应用程序,并且在其他一些库的帮助下自己完成并不难。
首先,对于视图,一个好的起点是使用 javascript 模板(例如 JavaScriptTemplates ) 将所有 HTML 标记保留在 javascript 文件之外并保留在单独的 html 文件中。这已经有很大帮助了。
至于控制器和模型,我借助 JavaScript 面向对象的语法来模拟类似的行为,如下所示:
通过这种方式,您可以以对您的应用程序有意义的方式保持组件分离。例如,我有一个 App.ui.views 对象,其中发生与 javascript 模板的交互。还有一个数据存储对象,其中包含表示数据库或其他信息之外的内容的所有对象。我个人的偏好是对特定类型的控制器进行更细粒度的分离(分成几个文件),因为它们在完整的 JavaScript 应用程序中可能会变得相当多。
I haven't used any specific frameworks, but I have developed an MVC-based production web app, and it's not that hard to do it yourself with the help of some other libraries.
Firstly, for Views, a good starting point is to use javascript templates (like JavaScriptTemplates) to keep all HTML markup out of your javascript files and in seperate html files. This already helps a lot.
As for Controllers and Models, I simulate similar behavior with the help of JavaScript object oriented syntax, like this:
In this way you can keep components separate in a way that makes sense for your app. For example, I had a App.ui.views object, where interaction with javascript templates takes place. There was also a datastore object, which contained all the Objects that represent something out of the database or other information. My personal preference was to have more fine-grained separation of specific types of controllers (seperated into several files), because they can become quite a lot in a full-scale javascript application.