Detailed Explanation of JavaScript Framework Design Patterns

Detailed Explanation of JavaScript Framework Design Patterns

mvc

insert image description here

Model(模型) - A model represents an object or JAVA POJO that stores and retrieves data. It can also contain logic to update the controller when the data changes.

View(視圖) - A view represents the visualization of the data contained in a model.

Controller(控制器) - The controller acts on the model and the view. It controls the flow of data to the model objects and updates the view when the data changes. It separates the view from the model.

It is one-way

mvp

insert image description here

The core of MVP lies in the presenter layer. The core of this layer is the operation of DOM elements. Taking the implementation of list page with jQuery as an example, the presenter mainly combines the data in the Model with the HTML tags through a loop and adds them to the View.

mvvm

insert image description here

The core of mvvm lies in the Model layer, the core of which is the operation on data. Compared with the mvp mode, our coding focus has shifted from the operation on dom to the operation on data. The VM layer displays data to the view layer and passes the data of the view layer to the Model layer. Vue is a typical example of viewModel

The source of Vue

Vue draws on react's virtual dom technology and angular's ng-directive technology

spa mpa

MPA: multi-page application

Features: The first loading is faster, and the subsequent loading is slower. The initial development cost is low, but the later maintenance cost is high.

SPA: single page application

The first load is slower, and the subsequent loads are faster. The initial development cost is high, but the later maintenance cost is low. (Mainly reused more)

createElement

var li = document.createElement(ele,src,content);
//ele The element to be created //src The attributes of the element //content The content of the elementvar li = document.createElement('li',{className='list-li'},'123');
<li className="list-li">123<li>

class

class Person {
   constructor(x,y) {
      this.x = x;
   }
   add() {
      console.log(this.x);
   }
}
var person = new Person(1,2);
typeof Person // function The essence of the class is a constructor Person === Person.prototype.constructor //true The class points to the prototype of the constructor person.hasOwnProperty(x); //true
person.hasOwnProperty(y); //false
person.hasOwnProperty(add); // false
This in the constructor points to the instantiated object, so x is a property of person and y and add are equivalent to adding to Person.prototype person.__proto__.hasOwnProperty(add) //true

The function in the class is equivalent to adding it to the prototype of the constructor.

Summarize

This article ends here. I hope it can be helpful to you. I also hope that you can pay more attention to more content on 123WORDPRESS.COM!

You may also be interested in:
  • JavaScript design pattern strategy pattern implementation principle detailed explanation
  • JavaScript Design Patterns – Visitor Pattern Principles and Usage Example Analysis
  • JavaScript Design Patterns – Template Method Pattern Principles and Usage Example Analysis
  • JavaScript Design Patterns – Observer Pattern Principles and Usage Examples
  • JavaScript Design Patterns – State Pattern Principles and Usage Examples
  • JavaScript and JQuery Framework Basics Tutorial

<<:  Detailed explanation of the principle and usage of MySQL stored procedures

>>:  Use prometheus to count the remaining available percentage of MySQL auto-increment primary keys

Recommend

MySQL REVOKE to delete user permissions

In MySQL, you can use the REVOKE statement to rem...

JS realizes the scrolling effect of announcement online

This article shares the specific code of JS to ac...

How to dynamically modify container port mapping in Docker

Preface: Docker port mapping is often done by map...

Docker-compose installation db2 database operation

It is troublesome to install the db2 database dir...

MySQL conditional query and or usage and priority example analysis

This article uses examples to illustrate the usag...

Introduction and use of five controllers in K8S

Table of contents Controller type of k8s Relation...

CSS Pick-up Arrows, Catalogs, Icons Implementation Code

1. CSS Miscellaneous Icons There are three ways t...

Windows Server 2016 Quick Start Guide to Deploy Remote Desktop Services

Now 2016 server supports multi-site https service...

Installation process of CentOS8 Linux 8.0.1905 (illustration)

As of now, the latest version of CentOS is CentOS...

Introduction to TypeScript interfaces

Table of contents 1. Interface definition 2. Attr...

Example of creating table statements for user Scott in MySQL version of Oracle

Overview: Oracle scott user has four tables, whic...

Docker installation tutorial in Linux environment

1. Installation environment Docker supports the f...

A brief discussion on Yahoo's 35 rules for front-end optimization

Abstract: Whether at work or in an interview, opt...

MySQL 5.7.21 Installer Installation Graphic Tutorial under Windows 10

Install MySQL and keep a note. I don’t know if it...