Quasar 1 Recaptcha v2

mail@pastecode.io avatar
unknown
html
a year ago
732 B
3
Indexable
Never
<template>
  <q-page class="flex flex-center">
    <div>
      <div id="g-recaptcha"></div>
    </div>
  </q-page>
</template>

<script>
export default {
  name: "PageIndex",
  mounted() {
    let recaptchaScript = document.createElement("script");
    recaptchaScript.setAttribute(
      "src",
      "https://www.google.com/recaptcha/api.js"
    );
    document.head.appendChild(recaptchaScript);

    setTimeout(() => {
      window.grecaptcha.render("g-recaptcha", {
        sitekey: "6LcnmAAkAAAAAFx6N74Rt3QUUb9HAhb4n8bnmda1",
        callback: this.verifyRecaptcha,
      });
    }, 200);
  },
  methods: {
    verifyRecaptcha(response) {
      console.log(response);
    },
  },
};
</script>