In development, we use $event a lot, so I’m going to print this out and see what it is. Take a look at this code:
<div @click="demoFun($event)" class="demo"> Click on me </div> <script>new Vue({
el:'.demo'.methods: {demoFun($event){
console.log($event)
}
}
})
Copy the code
So this code right here is let’s click on thisdiv
After, it prints$event
, let’s look at the output:You can see$event
There are so many things, the first is the type of event, in this case the mouse event. And the location of the click and so on, and here’s a more common property, which is$event.target
。 This is obviously the element that triggers the event, so we can use JS to change the style of the element or some other Dom manipulation!