# Multiple ways to implement MVVM, this chapter will first explain how to implement it based on defineProperty, which is similar to implementing VUE MVVM function. There are three implementations of this series, defineProperty (VUE), dirty check (Angular), and native JS implementations (publish subscriber mode)

Making the addressView the source code https://github.com/honeydlp/mvvm.git

#vue. Js uses data hijacking combined with publiser-subscriber mode, using ‘object.defineProperty ()’ to hijack the ‘setter’ and ‘getter’ of each property to publish messages to subscribers when data changes and trigger corresponding listener callbacks.

Look at the schematic first, then combine the code



Code map, today with the nuggets code always displayed in one line, so the screenshot, sorry ha, code on Github

Dom structure



The MVVM call



The MVVM implementation