Website Introduction is relatively simple
Example: $emit (' increment1 ', [KKK ']), directly see if there is no, can tell you, is to trigger a custom event Increment1 (or function name bar), [] parameter
On the case
<! DOCTYPE html>"UTF-8"> <title></title> "Counter-event-example"> <p>{{Total}}</p> <button-counter v-on:increment1="Incrementtotal"></button-counter> <button-counter v-on:increment2="Incrementtotal"></button-counter> </div> </body> <script src="Vue/vue.min.js"></script> <script>Vue.component ('Button-counter', {Template:'<button v-on:click= "increment" >{{counter}}</button>', Data:function () {return{counter:0}//Component data that's the way it is, functional, please note}, methods:{increment:function () { This. Counter + =1; This. $emit ('Increment1',[ A,'KKK']);//$emit } } }); NewVue ({el:'#counter-event-example', data:{total:0}, methods:{incrementtotal:function (e) { This. Total + =1; Console.log (e); } } }); </script>See Component Button-counter First
The event click is bound ———— >increment
Then this.counter + = 1; this. $emit (' increment1 ', [KKK ']);
This is the trigger event increment1, the reference is a bit messy, this side is not much clearer
Then <button-counter v-on:increment1= "Incrementtotal" ></button-counter>
V-on is the equivalent of listening, triggering incrementtotal.
Output//["KKK"]
There is no clear, if there is no understanding of the place, please correct me
Reference: HTTP://ARINU.ME/?P=50
The understanding of $emit in Vue.js