The MVVM pattern

MVVM is model-view-ViewModel, MVVM design principle is based on MVC, so MVVM is not a kind of innovation, at best is a kind of transformation, which ViewModel is a small innovation; As shown below:

The diagram above shows the relationship between the three; ViewMode can be regarded as a bridge between Model and View. View can bind Model through events, Model can bind View through data, and ViewMode can achieve complete separation of data and View.

Vue life cycle

beforeCreate Created beforemount mounted beforeUpdate updated beforeDestroy destroyed

Common instructions and functions in VUE

V-text only parses text information v-HTML can parse hypertext tags V-if/V-else -if/ V-else just like in javaScript, for judgment purposes. V-show controls the display and hiding of elements by controlling the display CSS property of the element. V-for loop v-on binding events can be used instead of v-bind one or more attributes of the element. Used to dynamically update the label content of an element on HTML V-slot slot V-pre skips compilation of itself and child elements V-model bi-directional binding of data V-clock Solves the problem of page flickering V-once renders only once

Difference between Watch and computed in VUE

Computed: 1) Has a caching mechanism 2) cannot accept parameters 3) cannot duplicate attributes in data Watch: 1) can accept two parameters 2) triggers a callback when listening and does some processing in the callback 3) Monitored letters must exist 4) allows asynchron