dongkyuuuu / vue3-recaptcha-v2 Goto Github PK
View Code? Open in Web Editor NEWreCAPTCHA v2 for Vue3 : CompositionAPI, Types
Home Page: https://www.npmjs.com/package/vue3-recaptcha-v2
License: MIT License
reCAPTCHA v2 for Vue3 : CompositionAPI, Types
Home Page: https://www.npmjs.com/package/vue3-recaptcha-v2
License: MIT License
Hello.
How i may use this https://developers.google.com/recaptcha/docs/verify#error_code_reference with this module ?
Thx.
Sorry, my mistake.
Can someone provide any advice on how to use this with v2 invisible captcha?
For people wanting to use this in Nuxt3 (rc3). It is possible with client side only plugin and component
in file plugins/recaptcha.client.ts
import install from "vue3-recaptcha-v2";
import { defineNuxtPlugin, useRuntimeConfig } from "#app";
export default defineNuxtPlugin((nuxtApp) => {
nuxtApp.vueApp.use(install, {
siteKey: useRuntimeConfig().public.recaptcha.siteKey
});
});
and in yourcomponent.vue
do
<template>
<div>
<client-only>
<VueRecaptcha
theme="light"
size="normal"
:tabindex="0"
@widgetId="recaptchaWidget = $event"
@verify="callbackVerify($event)"
@expired="callbackExpired()"
@fail="callbackFail()"
/>
</client-only>
</div>
</template>
....
The registering of the plugin will probably change in later versions of Nuxt3
For the life of me, I can't figure out how to erect a unit test harness for a project that includes vue3-recaptcha-v2. I know it's something I'm missing, but was hoping someone could point me in the right direction.
Simple app, which works fine:
<script setup>
import { ref } from "vue"
import { VueRecaptcha } from "vue3-recaptcha-v2"
const recaptchaWidget = ref(null)
</script>
<template>
<vue-recaptcha @widget-id="recaptchaWidget = $event" />
</template>
Unit test:
import { describe, it } from 'vitest'
import { mount, config } from '@vue/test-utils'
import VueRecaptcha from 'vue3-recaptcha-v2'
import App from '../App.vue'
config.plugins.VueWrapper.install(VueRecaptcha, { siteKey: 'fake-key'})
describe('App test', () => {
it('mount properly', () => {
mount(App)
})
})
A run of npm run test:unit
Yields the error:
stderr | src/__tests__/App.test.js > App test > mount properly
[Vue warn]: injection "Symbol(recaptchaSiteKey)" not found.
at <VueRecaptcha onWidgetId=fn >
at <App ref="VTU_COMPONENT" >
at <VTUROOT>
❯ src/__tests__/App.test.js (1)
❯ App test (1)
× mount properly
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Failed Tests 1 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
FAIL src/__tests__/App.test.js > App test > mount properly
TypeError: Cannot set properties of null (setting 'onload')
❯ node_modules/vue3-recaptcha-v2/dist/vue3-recaptcha-v2.js:1:1342
Versions
"dependencies": {
"vue": "^3.2.47",
"vue3-recaptcha-v2": "^1.0.1"
},
"devDependencies": {
"@vitejs/plugin-vue": "^4.0.0",
"@vue/test-utils": "^2.3.0",
"jsdom": "^21.1.0",
"vite": "^4.1.4",
"vitest": "^0.29.1"
}
Any pointers would be greatly appreciated.
such as China.
Replace it with https://recaptcha.net
, maybe is a good idea?
https://github.com/DongKyuuuu/vue3-recaptcha-v2/blob/main/src/config/install.ts#L28
hello! thank you very much for the plugin.
I have a problem.
I can't change language in reCaptcha when language option is changed in my project.
There isn't language change option in plugin.
Hello there is currently no language support can you add the &hl with param for props in template as well to support the locale ?
It has two versions of reCatpcha, v2 and v3.
This library is for v2?
Hi. I'm using it with Vite and got this error in dev mode:
vue3-recaptcha-v2 doesn't appear to be written in CJS, but also doesn't appear to be a valid ES module (i.e. it doesn't have "type": "module" or an .mjs extension for the entry point). Please contact the package author to fix.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.