1.vue using v ...... vm ...... m, mode, v ----> el, vm ----> new Vue (example), m ----> data data, so that a large number of operations from a distal dom elements of liberation.
2.vue responsive data is how to do?
By Object.defineproperty data hijacking
. 1 // VUE responsive data is how to do: data hijacking Object.defineProperty 2 the let obj = { . 3 name: "Bob" , . 4 Age: 32 , . 5 info: { . 6 B: 10 . 7 } . 8 } . 9 function the observe (obj) { 10 IF ( typeof obj === 'Object' ) { . 11 // redefined 12 is for (the let Key in obj) { 13 is defineReactive (obj, Key, obj [Key]); 14 } 15 } 16 } . 17 function defineReactive (obj, Key, value) { 18 is the observe (value); . 19 Object.defineProperty (obj, Key, { 20 is GET () { 21 is the console.log ( "GET," , value); 22 is return value ; 23 is }, 24 sET (newVal) { 25 the observe (newVal); // the value is set if the object, need to be monitored 26 is the console.log ( 'the modified data' ); 27 value = newVal; 28 } 29 }) 30 } 31 the observe (obj); 32 obj.age; // call GET () 33 is obj.info = {B: 20 is}; // calls the SET () 34 is / * 35 output: 36 GET, 32 37 [ data modified 38 * /
3.vue data hijacking refers example defined date data, an initial instance is not defined, and appending data having no response, object, and an array of data may be defined in the back, additive element, is responsive of.