First, two-way data binding, one of the weapons separated, different points, ng large, more complex functions, sometimes used on the mobile phone may not be very good, and Vue is the mini version of the angular, like, JQ and Zepto difference
1.controller, corresponding to the Vue inside is the new Vue ({el:}), this El, on the page, Ng needs to write the controller name, Vue does not need,
2.ng comes with HTTP service, Vue No, need to download vue-resource, of course, this is not big, about 12k;
3.ng instructions, corresponding to the Vue components, do not understand the plugin can be considered JQ, the difference is Ng is Directive,vue is Componen+directivet, where Ng transclusion, corresponding to the slot label Vue;
4. On the event, Ng is Ng-click,ng-mousedown,vue is v-on:event;
5 ng can filter, instruction and module order casually, but Vue finally write filter, then instantiate, otherwise will error, fail resolve filter
6.ng bottom is dirty detection, Vue seems to be the data tied to the prototype, this Vue performance should be good point,
7. Compare instruction system, personal feel ng's instruction is more annoying point, vue simple write; Vue instruction can access the name of the instruction via THIS.name, example:
Let's see Vue first.
<div id= "demo" v-demo:hello.a.b= "MSG" > </DIV>
Vue.directive (' demo ', {
Acceptstatement:true,
Bind:function (value) {
Console.log (this.expression)
This.el.style.color = ' red ';
This.el.innerHTML = this.msg
},
Update:function (value) {
This.el.innerHTML =
' name-' + this.name + ' <br> ' +//note the name here is Demo
' expression-' + this.expression + ' <br> ' + expression here is the expressions in the template
' argument-' + this.arg + ' <br> ' +//here arg is the parameter of the instruction which is the Hello
' Modifiers-' + json.stringify (this.modifiers) + ' <br> ' + the modified here is the modifier
' Value-' + value//Here is the value of the true MSG, which is the MSG in data
}
})
var demo = new Vue ({
El: ' #demo ',
Data: {
Msg:1,
Test: "Lyz"
}
})
See Angular again;
NG first creates the module and then the instruction method on the module
App.directive ("The name of the instruction", ["", function () {
return {
Returns various information about the instruction
])
A comparison of angular and Vue, several summaries: