Talking about MVVM Style Development Framework

What is the MVVM framework

The MVVM framework is a new type of framework structure evolved from the combination of MVP (Model View Presenter) mode and WPY. It is based on the original MVP framework and incorporates the new features of WPY to cope with the increasingly complex needs of customers.

Why does MVVM appear

To put it simply, before the MVVM style development framework came out, we usually put the server-side code in the browser, so that thousands of lines of js code are generated, which are connected to various types The CSS file and html file to display the view should be due to the lack of formal organization. More and more developers use the JavaScript framework, but the larger the front-end project, the lower the maintainability and scalability of the project. In order to solve this problem, many libraries have appeared on the front end to solve the maintenance and expansion of the project, but this type of library does not have a unified standard business logic layering. In summary, we have our current MVVM style development. frame.

MVVM design pattern

As shown
Insert picture description here

MVVM is the abbreviation of Model-View-ViewModel. Model is the model, which refers to the data transmitted by the backend. View is the view, which refers to the page that the user sees. ViewModel is the bridge connecting Model and View and is also the core of MVVM. So let's focus on the ViewModel.

ViewModel

Its job is to convert the data passed from the back-end into pages that the user sees. At the same time, it also needs to convert the pages that the user sees into data before passing it to the back-end, that is, in the MVVM framework, the View layer and The Model layer does not interact directly. They establish a connection through the ViewModel. The ViewModel needs to monitor the changes in the Model to change the View. At the same time, it also needs to monitor the changes in the View to notify the Model to change the data. This is two-way binding. The ViewModel needs to implement an observer. To monitor the changes in the data, and at the same time tell the View layer to make corresponding changes.

Guess you like

Origin blog.csdn.net/Y_X_gang/article/details/112002121