Click Event is not working
Hello dear people...
i wanted to make a simple click event for a button. Strangely it doesnt work and I tried out some things but I dont get it to work. Im pretty new in vue and nuxt to I would be happy to get some help :)
Code:
I hope to get some help :)
49 Replies
Hi @フェリックス. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
I see the issue with your click event. The button is correctly set up with
v-on:click="LoginCall"
, but you're trying to call the LoginCall
function when the button is clicked, while your actual registration logic is in the registerUser
function.
Here's how you can fix it:
I've made two changes:
1. Changed the click handler to call registerUser
instead of LoginCall
since that's the function that initiates the registration process
2. Used the shorthand @click
instead of v-on:click
(both work the same way, but @click
is more commonly used in Vue)
In Nuxt/Vue, the click event should work as long as you're calling the correct function. The @click
directive is the standard way to handle click events in Vue templates.
If you're still having issues, make sure that:
- Your component is properly mounted
- There are no console errors
- The PlayFab SDK is properly imported and initialized
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@781613262097219605> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
Hello,
Looks ok to me, any warning/error in the browser console ?
Nope nothing
thats what confuses me
Indeed....
What if you :
- Add a console.log directly in the script tag
- replace the function call in the click by a console log
Just to be extra sure, I would comment everything else in the script.
Does it work like that: <button @click="console.log('Test')">Tester</button> ?
The console.log directly in the script tag works fine
It should
<script setup lang="ts">
import rButton from '../components/registerButton.vue'
const testing = () => {
console.log('testing')
}
</script>
<template>
<form id="loginForm">
<label for="username">Username or Email:</label>
<input type="text" id="username" name="username" required>
<label for="password">Password:</label>
<input type="password" id="password" name="password" required>
<button type="submit">Login</button>
<button type="reset">Reset</button>
<p><a href="#">Forgot Password?</a></p>
<p><a href="#">Register</a></p>
</form>
<rButton />
<button @click="testing">Tester</button>
</template>
<style scoped>
</style>
With the rest of the script commented ?
i also had it with function testing() {} etc. also not working
with the console log directly behind the @click is also not working
Hum.... Is the project on github, stackblitz or something ?
GitHub
GitHub - ZeroOneJP/nuxt-playfab-test
Contribute to ZeroOneJP/nuxt-playfab-test development by creating an account on GitHub.
sure
i also tried it with components, so you going to find a button component under the components folder
Nice, let me have a little look
Can I just pull install and launch or is there third services dependencies?
There will be the playfab sdk but its only implemented in the button component
sure you can pull
Playfab is a videogame backend from Microsoft so dont worry c:
no problem ^^
A few things while it's launching
You normally don't need to import your components, they are auto imported
https://nuxt.com/docs/guide/directory-structure/components
ah okay
You can even put them in subfolder, it will by default be accessible with the folder name, you should have a read at the basic folders documentation 🙂
from some other reasons, you should have one root and one root only in each template (you'll understand if you read about pages, layouts, transitions and Nuxt UI)
So you should wrap your template content around <section> or <div> or anything is appropriate at the time
ah okay good to know thanks
Soooooo all your buttons work for me ^^"
ahhh okayy alright, so is this why it dont register the events?
but with your changes right? the div etc.
(don't mind the warnings it's my browser)

nop, that's for other stuff, I just npm install then npm run dev.... and it works
what browser are you using ? is it up to date ?
mainly safari but also with chrome and it didnt work
maybe try a brand new fresh pull, npm install then npm run dev ?
I´ll try one moment
if not... I have seriously no idea ^^", my only guess would be outdated browser or anything browser related
or maybe the node or npm version ?
I´m on my mac with Jetbrains Webstorm maybe thats a problem?
npm = 10.9.1 and node = v22.11.0
hum :/
well I don't use either so I can't tell you if there is any thing to look for, but I've seen people using it so it shouldn't
let me switch to my windows pc and try it there
sure
you can even create a https://stackblitz.com/ account and import the project (I think you can import, or pull, or juste quickly copy your files) and try from there too.
Always an easy way to see if it's environment related
I recently tried it in GitHub code spaces and it did not even started correctly haha
I didn't even know github was doing something like that too XD
In stackblitz you can directly create a nuxt 3 project, so you usually don't have any setup issue
dont even have node installed on windows xD i´ll try stackblitz
ahaha
that's the best to get very easy set up with node on windows : https://volta.sh/
Volta - The Hassle-Free JavaScript Tool Manager
Volta: Start your engines.
with a single command line you can install any version on any project
I know there is similar things for mac (no idea if volta works on mac)
man still now working
wow :/
no error ? not even in the npm install ?
ouhh never heard about that sounds nice
https://stackblitz.com/~/github.com/ZeroOneJP/nuxt-playfab-test
can you join with that?
no error
probably, it's booting
alright
it works for me ^^"
just to make it very utterly sure : you don't look at the stacklitz terminal or output or else.
You open the browser console with ctrl+shift+i and go in the console from there right ?
because that's clearly mystic that your console.log are working for me and not for you on stackblitz ^^"
my goooooooooooooooooooooooooooooooood
i looked at the terminal the whole time, i just thought about that, i should end my career
ahaha it happens :), at least it's solved XD
still thank you so much for your amazing help and trying :)
no problem, discovering vue and nuxt was a wonderful experience for me, I hope you'll enjoy it
yes im really excited for it, im building videogames with unreal engine 5 and c++, and we want to make the website with nuxt for it so ill keep pushing through :)
Good luck, the help is there if needed ^^