[Vuejs]-Why function doesn't work with a button component but does with a button html tag in VUE js?

0👍

First of all you have to add action as a prop to your AppButton, then you need to bind your click event using :click=”register”.

I made a sandbox with an example: https://codesandbox.io/embed/vue-button-action-c5kun

0👍

Happens because of form submit is not prevented.
Put @submit.prevent on form tag

<form class="login-form" action @submit.prevent>
  <label for="email">Register E-mail</label>
  <input type="email" name="email" v-model="email" />
  <label for="password">Register Password</label>
  <input type="text" name="password" v-model="password" />
  <div class="button-group">
     <AppButton action="register" name="Login" />
     <AppButton action="register" name="Login with Google" />
  </div>
</form>

Leave a comment