@click does not fire with q-btn
I’m new to Quasar and I’m trying to use the @click on a q-btn it doesn’t seem to fire. I’m working with an SPA dev mode. Button show and you can click it but it doesn’t show an alert.
<q-btn flat color=“brown” size=“lg” align=“right” label=“WATCHING” @click=“alert(‘hello world’)” />
this example will find for a method called “alert” in your vue component methods.
Try this instead:
<q-btn flat color=“brown” size=“lg” align=“right” label=“WATCHING” @click=“() => alert(‘hello world’)” />
or use a new method.
s.molinari last edited by s.molinari
It doesn’t work because Vue looks for the component instance method “alert” and since it isn’t there, throws an error. You should have seen this in your console, once clicking your button.
Btw, @ouaR your suggestion doesn’t work either, as the example also shows. The same error happens.
Makes sense too, as you’d want to do more in your click handler than just show an alert, right?
Hi, I re-installed the quasar cli and now it works. I can only assume I had some package dependency that was causing the issue. Thanks for the responses.