Quasar Recaptcha v2

 avatar
unknown
html
2 years ago
922 B
4
Indexable
<template>
  <q-page class="flex flex-center">
    <div>
      <vue-recaptcha
        sitekey="6LcnmAAkAAAAAFx6N74Rt3QUUb9HAhb4n8bnmda1"
        @verify="verifyMethod"
      ></vue-recaptcha>
      <div v-if="grecaptcha.error" class="q-mt-xs text-red">
        Pastikan anda bukan robot
      </div>

      <q-btn color="primary" class="q-mt-md" @click="submit">Submit</q-btn>
    </div>
  </q-page>
</template>

<script>
import { VueRecaptcha } from "vue-recaptcha";

export default {
  components: {
    VueRecaptcha,
  },
  data: () => ({
    grecaptcha: {
      error: false,
      response: null,
    },
  }),
  methods: {
    verifyMethod(response) {
      this.grecaptcha.response = response;
    },
    submit() {
      this.grecaptcha.error = false;

      if (!this.grecaptcha.response) {
        return (this.grecaptcha.error = true);
      }
    },
  },
};
</script>
Editor is loading...