[Vuejs]-Nuxt3 Button doesn't register @click event

0👍

I updated my machine, turned it off, tried again today and it worked.

I have no further explanation…

2👍

The usual way of using a console.log is by using a function to call it (rather than doing it directly from the template), like the following.
Using the CompositionAPI:

<script setup>
function consoleHitOn() {
  console.log('I got hit on')
}
</script>

<template>
  <button @click="consoleHitOn">HIT ME BABY</button>
</template>

Using the OptionsAPI, you could achieve the same with a hack by doing this

<script>
export default {
  computed: {
    console: () => console,
  }
}
</script>

<template>
  <button @click="console.log('I got hit on')">HIT ME BABY</button>
</template>

I’m not sure if there is a way of writing the same kind of hack with CompositionAPI, but even if there is I do not really recommend it anyway.


PS: one thing for sure is that it’s totally not related to TailwindCSS.
Tailwind is for the style, nothing concerning the event listeners in a Vue app.

👤kissu

1👍

Below command fixed issue at my end.
just npm run build when its build successfully do npm run dev it might fix your issue it worked at my end,

when I run build I found few issues, fixed them and run again dev

Leave a comment