a MVP and MVVM is front end design patterns, are peculiar to the front and back end separation mode, front and back side before the separation is the MVC pattern, mainly concentrated in the back-end business logic, even rendering of the page in the back-end,
1, MVP patterns used in conventional front-end developer
M: data layer model
V: the view layer view
P: control layer presenter
MVP pattern is the core of the p-type, fire an event when the view, to P, P or to M call ajax to get the data, or to operate DOM change V (view), the MVP
There is a big part of the code is in the P, P contains a lot of DOM manipulation,
2, MVVM
M: data layer model
V: the view layer view
VM: vue own viewModel layer
Using the vue development focus on M layer, data-oriented programming, no longer pay attention to the DOM manipulation, trying to or changes in operating data, the vm to the appropriate data, don't enter
Implementation of the main line of DOM manipulation, the vm layer used es5 object. Definproperties and virtual DOM mechanism,
* Vue attributes or using the arrow on the callback function, because the arrow function and not this, this will act as a variable to
Until I find the higher lexical scope search, and can lead to wrong
2, global component and local components
1, the global components
Vue.com ponent (TodoItem, {
Props: [" item "],//child components received data
The template: "& lt; Li> {{item}} & lt;/li>"
})
2, the local component
* use local components, need to Vue instances to register
let TodoItem={
Props: [' item '],
The template: '... '
}
CodePudding user response: