search
HomeWeb Front-endJS TutorialFront-end framework management

Front-end framework management

Mar 19, 2018 pm 05:13 PM
front endframemanage

This time I will bring you front-end framework management. What are the precautions for front-end framework management? Here are actual cases, let’s take a look.

The three most popular front-end frameworks today are Angular2+, Vue, and React. All of them use the ideas of componentization and modularization to make front-end development more standardized.

But the shortcomings are also obvious. In addition to incomplete documentation, lack of cases, and high learning costs, state management between components is also a big problem. Componentization is a good thing, but if the data flow between components is not properly handled, it will cause negative impacts such as project confusion and difficulty in maintenance.

Let’s first talk about why state management is needed:

For example, two lists refer to the same data source. The user makes changes to one of the lists, and the other list The data will also change accordingly. The solution when using angular1 is very simple, just use $rootScope. But when it comes to the three major frameworks, there is no concept of $rootScope. What should I do if I want to achieve synchronous update of data?

Some people may say that this is simple. When the user makes changes to the first table, we send a message to the second table and let it change the corresponding data. But what if there are 10 tables or 20 tables? Are you going to give notices one by one? If other components also use this data source, will they also be notified of updates?

So this solution may be feasible when the project is simple, but when the project becomes complex, problems will be exposed immediately. In order to prevent future projects from being overturned, we should still think about it from the beginning.

The concept of state management is to deal with complex data flow.

The three major frameworks implement state management methods:

Vue: Vuex

React: Redux (dva.js)

Angular2+: Redux ( ngrx)

Although the three major frameworks have different solutions for implementing state management, the underlying ideas are the same. Here’s a rough introduction: In order to achieve state management in the

project, has added several new modules: reducers, effects, services, models. If it is angular2+, there are also actions.

Let’s first talk about the functions of these modules:

models: data model. Stores the data itself and methods for modifying the data. In angular2+, models store entities. Those who have studied back-end should be familiar with it. It is a statement about data.

reducers: Responsible for synchronization operations. For example, the requested form data is stored in the data model, the user adds/delete a certain piece of data, and the original data is modified.

services: An encapsulation of the action of requesting data, generally including methods for obtaining data. Such as getList(), getUsers().

effects: Responsible for asynchronous operations. For example, after receiving the user's request action, call service to request data from the server. If it succeeds, it will call reducers to save the data. If it fails, it will perform another action.

angular2+ also abstracts a layer of actions, which is an encapsulation of various actions. For example, data is loaded, the data is loaded successfully, the user deletes the data, etc. Contains the type of data and payload (data used to modify the data)

A user operation, such as searching for the corresponding product, when the user presses the confirmation button, the entire process can be summarized as :

The user issues instructions -> dispatch calls reducers to modify the status, and the corresponding component enters the loading state -> effects calls services to obtain data -> The data is obtained successfully, calls reducers to save the data and ends loading -> Rendering Go to View.

When reducers are called to update data, all views bound to the model will be updated synchronously, and each processing logic becomes quite clear. Although the project complexity will increase, it will definitely be much more convenient to maintain.

If you find it difficult to understand, you can start with these two cases:

vuex counter + list display: http://www.cnblogs.com/axel10/p/8536688.html

dva.js counter + list display: http://www.cnblogs.com/axel10/p/8503782.html

The most suitable one for getting started is Vue, then React (using dva.js), and the most difficult one is angular2+. Angular2+ involves Rxjs and TypeScript, and there are many knowledge points. No matter whether it is difficult or not, always remember to start from the shallower to the deeper, and don’t fantasize about reaching the sky in one step. If you are not even familiar with angular1, then please use angular1 well first, understand MVC ideas well, and then get involved in the three major frameworks. Otherwise, you are likely to get half the result with twice the result and waste a lot of time.

As a front-end engineer, if possible, it is recommended to learn a back-end language, such as java, c#, which will be of great help in understanding the front-end framework.

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!

Recommended reading:

What classes define components in React

Vue.js form input binding

The above is the detailed content of Front-end framework management. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
The Relationship Between JavaScript, C  , and BrowsersThe Relationship Between JavaScript, C , and BrowsersMay 01, 2025 am 12:06 AM

Introduction I know you may find it strange, what exactly does JavaScript, C and browser have to do? They seem to be unrelated, but in fact, they play a very important role in modern web development. Today we will discuss the close connection between these three. Through this article, you will learn how JavaScript runs in the browser, the role of C in the browser engine, and how they work together to drive rendering and interaction of web pages. We all know the relationship between JavaScript and browser. JavaScript is the core language of front-end development. It runs directly in the browser, making web pages vivid and interesting. Have you ever wondered why JavaScr

Node.js Streams with TypeScriptNode.js Streams with TypeScriptApr 30, 2025 am 08:22 AM

Node.js excels at efficient I/O, largely thanks to streams. Streams process data incrementally, avoiding memory overload—ideal for large files, network tasks, and real-time applications. Combining streams with TypeScript's type safety creates a powe

Python vs. JavaScript: Performance and Efficiency ConsiderationsPython vs. JavaScript: Performance and Efficiency ConsiderationsApr 30, 2025 am 12:08 AM

The differences in performance and efficiency between Python and JavaScript are mainly reflected in: 1) As an interpreted language, Python runs slowly but has high development efficiency and is suitable for rapid prototype development; 2) JavaScript is limited to single thread in the browser, but multi-threading and asynchronous I/O can be used to improve performance in Node.js, and both have advantages in actual projects.

The Origins of JavaScript: Exploring Its Implementation LanguageThe Origins of JavaScript: Exploring Its Implementation LanguageApr 29, 2025 am 12:51 AM

JavaScript originated in 1995 and was created by Brandon Ike, and realized the language into C. 1.C language provides high performance and system-level programming capabilities for JavaScript. 2. JavaScript's memory management and performance optimization rely on C language. 3. The cross-platform feature of C language helps JavaScript run efficiently on different operating systems.

Behind the Scenes: What Language Powers JavaScript?Behind the Scenes: What Language Powers JavaScript?Apr 28, 2025 am 12:01 AM

JavaScript runs in browsers and Node.js environments and relies on the JavaScript engine to parse and execute code. 1) Generate abstract syntax tree (AST) in the parsing stage; 2) convert AST into bytecode or machine code in the compilation stage; 3) execute the compiled code in the execution stage.

The Future of Python and JavaScript: Trends and PredictionsThe Future of Python and JavaScript: Trends and PredictionsApr 27, 2025 am 12:21 AM

The future trends of Python and JavaScript include: 1. Python will consolidate its position in the fields of scientific computing and AI, 2. JavaScript will promote the development of web technology, 3. Cross-platform development will become a hot topic, and 4. Performance optimization will be the focus. Both will continue to expand application scenarios in their respective fields and make more breakthroughs in performance.

Python vs. JavaScript: Development Environments and ToolsPython vs. JavaScript: Development Environments and ToolsApr 26, 2025 am 12:09 AM

Both Python and JavaScript's choices in development environments are important. 1) Python's development environment includes PyCharm, JupyterNotebook and Anaconda, which are suitable for data science and rapid prototyping. 2) The development environment of JavaScript includes Node.js, VSCode and Webpack, which are suitable for front-end and back-end development. Choosing the right tools according to project needs can improve development efficiency and project success rate.

Is JavaScript Written in C? Examining the EvidenceIs JavaScript Written in C? Examining the EvidenceApr 25, 2025 am 12:15 AM

Yes, the engine core of JavaScript is written in C. 1) The C language provides efficient performance and underlying control, which is suitable for the development of JavaScript engine. 2) Taking the V8 engine as an example, its core is written in C, combining the efficiency and object-oriented characteristics of C. 3) The working principle of the JavaScript engine includes parsing, compiling and execution, and the C language plays a key role in these processes.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.