Understanding of front-end MVVM development

  • MVVM is model, View, ViewModel
    1. View stands for UI view and is responsible for data display.
    2. Model stands for data model. Both data and business logic are defined here. (What is data model: data structure: describe the attributes and connections of database objects, data operation: add, delete, change and check, data constraints: such as a student can not have two student numbers) (What is business logic: the core code to achieve a function, such as the realization of the sum of several numbers)
    3. The ViewModel representative connects the two, listens for changes in the Model and controls updates to the view. Handle user interactions.
  • View and Model are not directly related, through the viewModel, model and viewModel are bidirectional binding relationship.
  • So data changes in the Model layer trigger a refresh in the View layer. Data changes in the View layer due to user interaction will also be synchronized in the Model!
  • Therefore, automatic data synchronization between view and Model is realized! Engineers only need to maintain data. You don’t need to manipulate the DOM yourself!