vue.js - What is the difference between ViewModel and Controller?
習慣沉默2017-05-16 17:05:24
0
2
649
vue.js belongs to the MVVM framework, and angularjs belongs to the MVC framework, right? What's the difference between them in this aspect? What is the difference between VM in MVVM and C in MVC framework?
Simply put, the tasks that the Controller has to perform are more comprehensive, including a lot of business logic. The ViewModel simplifies or even eliminates the business logic. The main job is just to assemble the data in the Model into data suitable for use by the View. Compared to Vue, Angular is indeed an MVC framework. In fact, for the front-end, little or no business logic is required, so the back-end design structure of MVC is actually not suitable. Therefore, structures such as MVP and MVVM that weaken business logic are becoming more and more popular in the front-end field.
Simply put, the tasks that the Controller has to perform are more comprehensive, including a lot of business logic. The ViewModel simplifies or even eliminates the business logic. The main job is just to assemble the data in the Model into data suitable for use by the View.
Compared to Vue, Angular is indeed an MVC framework. In fact, for the front-end, little or no business logic is required, so the back-end design structure of MVC is actually not suitable. Therefore, structures such as MVP and MVVM that weaken business logic are becoming more and more popular in the front-end field.
MVC
Routing to the controller, the controller needs to process the model (data) by itself, and then re-render to generate the view (UI)
MVVM
Data-driven, once the model changes, its view (UI) will change.