Comments (13)
I resolved this issue:
First, in template html here is my code:
<template>
<v-form @submit.prevent="submitForm">
<v-text-field
class="mb-3"
label="Username"
prepend-icon="mdi-account"
variant="outlined"
v-model="username.value.value"
:error-messages="username.errorMessage.value"
></v-text-field>
<v-text-field
label="Password"
prepend-icon="mdi-lock"
variant="outlined"
:type="showPassword ? 'text':'password'"
:append-inner-icon="showPassword ? 'mdi-eye':'mdi-eye-off'"
@click:append-inner="showPassword =! showPassword"
v-model="password.value.value"
:error-messages="password.errorMessage.value"
></v-text-field>
<v-btn
type="submit"
class="w-100 g-recaptcha"
data-sitekey="reCAPTCHA_site_key"
data-callback='onSubmit'
data-action='submit'
>
Login
</v-btn>
</v-form>
</template>
Script:
<script lang="ts" setup>
import {useField, useForm} from 'vee-validate';
import { VueReCaptcha, useReCaptcha } from 'vue-recaptcha-v3'
...
const { vueApp } = useNuxtApp();
vueApp.use(VueReCaptcha, {
siteKey: 'key-site',
loaderOptions: {
renderParameters: {
hl: 'en'
}
}
})
const recaptchaInstance = useReCaptcha();
const submitForm = handleSubmit(async values => {
await recaptchaInstance?.recaptchaLoaded();
const token = await recaptchaInstance?.executeRecaptcha('submit')
values.googleReCaptchaToken = token
console.log('Google recaptChaToken: ', values.googleReCaptchaToken);
});
from vue-recaptcha-v3.
Hi,
I did as above for nuxt 3 .
but I get this error
do you know why is that?
from vue-recaptcha-v3.
I have run into this issue before when trying to initialize it in a method that is asynchronous, what I ended up doing was making a composable file
import { VueReCaptcha, useReCaptcha } from 'vue-recaptcha-v3';
export function useVueRecaptcha(pubicKey) {
const { vueApp } = useNuxtApp();
vueApp.use(VueReCaptcha, {
siteKey: pubicKey,
loaderOptions: { autoHideBadge: true },
});
const { executeRecaptcha, recaptchaLoaded } = useReCaptcha();
return async (action) => {
await recaptchaLoaded();
return await executeRecaptcha(action);
};
}
And then on mounted I call the composable and I pass in my siteKey to initialize the package and on submit I call recaptcha
data() {
return {
recaptcha: null,
}
}
mounted() {
this.recaptcha = useVueRecaptcha(this.recaptchaKey);
},
methods: {
async onSubmit() {
const recaptchaToken = await this.recaptcha('login');
}
}
from vue-recaptcha-v3.
ty man u saved my time♥
from vue-recaptcha-v3.
I've tried that , but it didn't work again .
and the same error is shown
from vue-recaptcha-v3.
For those who are facing the error
Hi,
I did as above for nuxt 3 .
but I get this error
do you know why is that?
Try this instead:
ort const useVueRecaptcha = async () => {
const { vueApp } = useNuxtApp()
vueApp.use(VueReCaptcha, {
siteKey: '6Lc1dLcjAAAAAJv-IVAfPpKH3DG42HIOGbHapY-Y',
loaderOptions: {
autoHideBadge: true,
},
})
const recaptchaInstance = useReCaptcha()
await recaptchaInstance?.recaptchaLoaded()
return await recaptchaInstance?.executeRecaptcha('login')
}
from vue-recaptcha-v3.
Hi, I did as above for nuxt 3 . but I get this error
do you know why is that?
I have same problem
from vue-recaptcha-v3.
I resolved this issue: First, in template html here is my code:
<template> <v-form @submit.prevent="submitForm"> <v-text-field class="mb-3" label="Username" prepend-icon="mdi-account" variant="outlined" v-model="username.value.value" :error-messages="username.errorMessage.value" ></v-text-field> <v-text-field label="Password" prepend-icon="mdi-lock" variant="outlined" :type="showPassword ? 'text':'password'" :append-inner-icon="showPassword ? 'mdi-eye':'mdi-eye-off'" @click:append-inner="showPassword =! showPassword" v-model="password.value.value" :error-messages="password.errorMessage.value" ></v-text-field> <v-btn type="submit" class="w-100 g-recaptcha" data-sitekey="reCAPTCHA_site_key" data-callback='onSubmit' data-action='submit' > Login </v-btn> </v-form> </template>
Script:
<script lang="ts" setup> import {useField, useForm} from 'vee-validate'; import { VueReCaptcha, useReCaptcha } from 'vue-recaptcha-v3' ... const { vueApp } = useNuxtApp(); vueApp.use(VueReCaptcha, { siteKey: 'key-site', loaderOptions: { renderParameters: { hl: 'en' } } }) const recaptchaInstance = useReCaptcha(); const submitForm = handleSubmit(async values => { await recaptchaInstance?.recaptchaLoaded(); const token = await recaptchaInstance?.executeRecaptcha('submit') values.googleReCaptchaToken = token console.log('Google recaptChaToken: ', values.googleReCaptchaToken); });
Hello, when i tried to use the usual button component, i get this error:
even tho i already change the data-sitekey="reCAPTCHA_site_key" to my site-key. does anyone knows why i get this error? thank you
from vue-recaptcha-v3.
For some reason, the same code didn't work in composable, but worked in component. no idea, but thanks for all the answers
from vue-recaptcha-v3.
Where We can find the reCAPTCHA V3 is working well?
Thanks
from vue-recaptcha-v3.
Where We can find the reCAPTCHA V3 is working well?
Thanks
Same Here
from vue-recaptcha-v3.
Maybe this article could help us --> https://dev.to/elquimeras/integrate-recaptcha-v3-on-nuxt3-app-1gma
from vue-recaptcha-v3.
Related Issues (20)
- How to locolize widget? HOT 3
- Localization
- Cannot use recaptcha on a specific component HOT 3
- Vue 3.0 composition HOT 3
- Property 'executeRecaptcha' does not exist on type 'IReCaptchaComposition | undefined' HOT 6
- Error "incorrect-captcha-sol" and "timeout-or-duplicate" HOT 3
- Latest version is not compatible to use with Vue2 HOT 2
- useReCaptcha composable returns undefined
- CSP violation in production HOT 4
- uncaught (in promise) null HOT 2
- CSP Issue HOT 1
- hideBadge and showBadge methods do not exist HOT 2
- Adding container creates reCAPTCHA ERROR: Invalid domain for site key
- Is "login" part of the syntax? HOT 1
- Loading the recaptcha only in one page HOT 3
- --------
- Reduce unused JavaScript
- Load on local component instead of global HOT 2
- Documentation on how to access instance from Vue 3 Composition HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vue-recaptcha-v3.