M:M corresponding to the MVC
V:V corresponding to the MVC
VM:viewModel, is to separate out the data loading and processing functions of the controller in MVC
MVVM be Web A very popular development pattern on the front end， take advantage of MVVM can make our code more focused on handling business logic rather than caring about DOM operations。 current famous MVVM The framework has vue, avalon, angular etc.， Each of these frameworks has its own merits， But the idea behind the implementation is largely the same： Data binding harmony View Refresh。 withMVC the same as， The main purpose is to separate the view（View） and models（Model）。View Can be independent ofModel Changes and modifications， anViewModel can be bound to a different"View" upper， properView The time of changeModel Can be unchanged， properModel The time of changeView It can also remain the same。
In MVVM, data is the core. Due to the two-way binding between VIewModel and View, the data in the ViewModel is manipulated and synchronized to the DOM, and we monitor the user's changes to the DOM through DOM events, which are also synchronized to the ViewModel.
Benefits of MVVM design pattern
1.Two-way binding technique, when the Model changes, the View-Model is automatically updated and the View is automatically changed. It's good to have consistency in the data, don't worry, in one piece of the module the data is this value, in another piece it's another value. That's why the MVVM pattern is sometimes called: the model-view-binder pattern.
2.The View is further enhanced with some of the functionality of the control, and if you want to enhance it infinitely, even almost all of the controller's functionality can be migrated to individual Views (although this is not desirable, then the View does something that is not part of its responsibility). A View can have its own View-Model just like a controller.
3.The controller is greatly slimmed down as most of the controller's functions are moved to the View to be handled. No more fretting about seeing huge controller logic.
4.A function can be abstracted from the data processing part of the View or ViewController to handle the mod. This way they specialize in page layout and page jumps, and they are necessarily a step more simplified.
Disadvantages of MVVM design pattern
1.Data binding makes bugs hard to debug. If you see an interface exception, it could be a bug in your View's code or a problem with the Model's code. Data binding makes it less easy to locate the original problem when a bug in one location is quickly passed to another location.
2.A large module in the mod will also be very large, although the use of easy to use is also easy to ensure the consistency of the data, when held for a long time, not to free memory caused to spend more memory.
3.Two-way data binding is not conducive to code reuse. The most common reuse for client-side development is View, but the data bi-directional binding technique allows you to bind a mod to a View all in one, with different mods for different modules. Then you can't simply reuse the View.
This article was written by
Source Code Era H5 Front End Discipline
>>1、Macro College holds the second academic lecture for the university celebration2、Zhejiang to build superhighway with full support for autonomous driving3、Today at 0152 AM the BCH public chain officially completed its hard fork4、Robot Programming Series Captain Dragonfly5、Five Cybersecurity Predictions for 2018