如何制作基于组件的单页Web应用程序? [英] How to make component-based single page web application?

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

问题描述

这可能是一个非常模糊的问题。

This is probably a very vague question.

假设我有一个单页Web应用程序,它使用 AJAX 与服务器中的REST服务进行通信。它由一个整体式 HTML 和一个整体式 CSS 文件组成,其中包括应用程序的所有表单,对话框和其他GUI元素应该显示在屏幕上。

Suppose I have a single-page web application, which uses AJAX to communicate with REST services in the server. It consists of one monolithic HTML and one monolithic CSS file, which include all forms, dialogs and other GUI elements the application should display on the screen.

现在,我想将其分解为各个部分(例如,登录表单注册表单错误对话框等)。我猜每个组件都应该包含自己的 HTML CSS JavaScript 文件。此外,应该有某种机制来加载所有这些组件并将它们放在一起以显示在页面中。

Now I would like to break it down into components (e.g. login form, sign-up form, error dialog, etc.). I guess each component should contain its own HTML, CSS, and JavaScript files. Besides there should be some mechanism to load all these components and put them together to display in the page.

实现该目标的推荐方法/模式是什么?

What are the recommended approaches/patterns to achieve that?

推荐答案

我建议您通过研究Todo MVC项目来开始研究构建单页js应用程序。

I suggest starting your research on building single page js apps by looking at the Todo MVC projects.

https://github.com/addyosmani/todomvc

从上面的URL


为了帮助解决此问题,我们创建了TodoMVC-一个项目,其中
提供了使用MV *概念实现的相同Todo应用程序,其中
最受欢迎。今天的JavaScript MV *框架。

To help solve this problem, we created TodoMVC - a project which offers the same Todo application implemented using MV* concepts in most of the popular JavaScript MV* frameworks of today.

因此,这将显示同一项目是如何使用不同的库构建的,您可以尝试一个或多个找出最适合您的方法。

So, this will show how the same project's built with different libs and you can try one or more out and see what best works for you.

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

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