Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

What is the difference between mvvm mode and mvc mode

Shulou Source: shulou.com Published: 2022-06-03 03:20:26 09月16日 Update

What is the difference between mvvm mode and mvc mode? In view of this problem, this article introduces the corresponding analysis and answers in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible way.

Difference: Controller in MVC evolved into viewModel in MVVM. MVVM mainly solves the problems such as the degradation of page rendering performance and slow loading speed caused by a large number of DOM operations in MVC. When and Model change frequently in MVVM, developers need to actively update to View.

What is MVVM?

Under the MVVM framework, the view and the model can not communicate directly, but can only interact through ViewModel, it can monitor the changes of the data, and then notify the view to update automatically, and when the user operates the view, VM can also monitor the changes of the view, and then notify the data to make corresponding changes, which actually realizes the two-way binding of data. And V and VM can communicate.

An example of the picture is as follows:

Advantages of MVVM mode:

Low coupling: View can be changed and modified independently of Model, a ViewModel can be bound to different View, Model can not change when View changes, and View can not change when Model changes.

Reusability: you can put some view logic in a ViewModel and let many View reuse this view logic.

Independent development: developers can focus on business logic and data development, designers can focus on page design.

What is MVC?

MVC is one of the most widely used software architectures. Generally speaking, MVC is divided into:

Model (model), View (view), Controller (controller). This is mainly based on the purpose of layering to separate the responsibilities of each other.

View generally uses Controller to communicate with Model.

Controller is the coordinator of Model and View, and View and Model are not in direct contact. It's basically an one-way connection.

M and V mean the same as M and V in MVVM. C, or Controller, refers to the business logic of the page. MVC is an one-way communication. That is, View and Model, must use Controller to connect the preceding and the next.

Third, the difference between mvc and mvvm:

The difference between MVC and MVVM is not that VM completely replaces C _ Controller ViewModel exists to extract the business logic shown in Controller, not to replace Controller, other view operations should be implemented in Controller. In other words, MVVM implements the reuse of business logic components.

-Controller in MVC evolved into ViewModel in MVVM

-MVVM displays view layers through data rather than node operations

-MVVM mainly solves the problem that a large number of dom operations in MVC degrade the performance of page rendering, slow down the loading speed, and affect the user experience.

The answer to the question about the difference between mvvm mode and mvc mode is shared here. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel to learn more about it.

Tags: Views logic changes patterns business data problems pages development contacts communications that is people one-way performance meaning time more models users Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Microsoft Shulou Information MariaDB NVidia