No events are generated in Vue

There is a js file that is compiled using Laravel Mix. It previously had 2 components, after which there was a need to register a new one. After I wrote down all the necessary logic, I decided to run it. Collected the bundle. Checking it out. Does not respond to pressing. Everything is correct in the code. There were no errors during the build. The developer console is also empty. I decided to just throw in console. log. You never know. Nothing helped. As a result, I made a copy of the current source.vue, and in the original erased everything and wrote just

<template>
<v-btn @click="console.log('adfesfwf')">ajvarhe</v-btn>
</template>

Yes, I have Vuetify enabled. The buttons are displayed correctly, but the console is empty when clicked. At the same time, I use DevTools for Vue, where it is very convenient to view the sent events. During the entire time of debugging this error, not a single event was recorded. At the same time, the hooks work (I only checked created). I tried to create a completely different component. Exactly the same problem. Want pay attention to the fact that the previous 2 components work quite correctly. As long as there were no reassembles, the events work.

1 answers

The event will be triggered on the component only if the component generates this event $emit('click'). In other words, in your case, <v-btn @click="console.log('adfesfwf')"></v-btn> is equivalent to <v-btn @bla-bla-bla="console.log('adfesfwf')"></v-btn>. If you want to subscribe to a native event on a component, you need to use the special modifier native. In your case, it will look like this <v-btn @click.native="console.log('adfesfwf')">ajvarhe</v-btn>

 1
Author: Дмытрык, 2020-03-10 08:56:46