Coder Social home page Coder Social logo

Comments (3)

jals1212 avatar jals1212 commented on July 20, 2024 3

Use autoHideBadge in loaderOptions

loaderOptions: {
    autoHideBadge: true
}

Create a wrapper composable to use it.

// use-recaptcha.ts
import { onMounted, onUnmounted } from 'vue';
import {
  IReCaptchaComposition,
  useReCaptcha as _useReCaptcha,
} from 'vue-recaptcha-v3';

export const useReCaptcha = () => {
  const { executeRecaptcha, isLoaded, instance, recaptchaLoaded } =
    _useReCaptcha() as IReCaptchaComposition;

  onMounted(() => {
    instance.value?.showBadge();
  });

  onUnmounted(() => {
    instance.value?.hideBadge();
  });

  return {
    isLoaded,
    executeRecaptcha,
    recaptchaLoaded,
  };
};

This will toggle it when you use it in a page component.

from vue-recaptcha-v3.

nekooee avatar nekooee commented on July 20, 2024 1

Use autoHideBadge in loaderOptions

loaderOptions: {
    autoHideBadge: true
}

Create a wrapper composable to use it.

// use-recaptcha.ts
import { onMounted, onUnmounted } from 'vue';
import {
  IReCaptchaComposition,
  useReCaptcha as _useReCaptcha,
} from 'vue-recaptcha-v3';

export const useReCaptcha = () => {
  const { executeRecaptcha, isLoaded, instance, recaptchaLoaded } =
    _useReCaptcha() as IReCaptchaComposition;

  onMounted(() => {
    instance.value?.showBadge();
  });

  onUnmounted(() => {
    instance.value?.hideBadge();
  });

  return {
    isLoaded,
    executeRecaptcha,
    recaptchaLoaded,
  };
};

This will toggle it when you use it in a page component.

But this only hides the badge and the script is loaded in the background on all pages.
I'm using Laravel combined with Vue and I only need the google recaptcha script to be loaded on one of the pages and not on all the pages.
It's strange that this component doesn't provide any solution for loading locally, and it's too bad that an extra script is loaded all over the site.

from vue-recaptcha-v3.

mssayari avatar mssayari commented on July 20, 2024

Hey @cod3rshotout ,
Have you found any solution for this problem?
I only need it in my register page but when we add it in our main, it appears on all pages!

from vue-recaptcha-v3.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.