Home > Article > Web Front-end > Understanding MVVM
Understanding of MVVM
Overview
MVVM It is a variant and advancement of MVC. Conceptually, it is a model that truly separates page and data logic. It puts the data binding work into a JS to implement, and the main function of this JS file is to complete data binding. That is, bind the model to the elements of the UI.
MVVM mode can be divided into:
M----> model model layer (generally used for data storage, storing some business logic), That is what we call the data model.
V-----> view view layer (interface), used to display data.
VM—> ViewModel (view model), which is $scope.
In actual applications, more page interactions are performed, and the final processing is submitted to the server all at once (weakening the function of the controller in MVC), which enhances the use of views and models, so the This is called MVVM.
Advantages of MVVM pattern
● Low coupling: View can change and modify independently of Model, and the same ViewModel can be duplicated by multiple Views It can be used; and changes in View and Model can be made without affecting each other;
● Reusability: You can put some view logic in ViewModel to reuse multiple Views;
● Independent development: Developers can focus on the development of business logic and data;
● Testability: The clear View layering makes it easier and simpler to test the business logic of the presentation layer.
This article comes from the js tutorial column, welcome to learn!
The above is the detailed content of Understanding MVVM. For more information, please follow other related articles on the PHP Chinese website!