vue2-recaptchav3
Vue2 Google Recaptcha V3
Usage in form:
<form>
<input type="hidden" name="token" v-model="googleToken" />
<GoogleCaptcha sitekey="yourSiteKey" action="yourPageAction" v-on:google_captcha_token="updateToken" ref="captcha"></GoogleCaptcha>
</form>
Import statement and event handling:
<script>
import GoogleCaptcha from 'vue2-recaptchav3';
export default {
data(){
return {
googleToken: null,
...
}
},
methods: {
updateToken(payload){
this.googleToken = payload.response_token;
},
formSubmit(){
this.$refs.captcha.generateManualToken().then((token) => {
//use token here
});
}
...
}
}
</script>
Every time the action changes a new token is generated.
This allows you to generate tokens based on the page the user is on or based on each individual form
Related Packages
Version History
| Version | Released | Vue | License |
|---|---|---|---|
| 1.0.7 | ^2.6.10 | MIT | |
| 1.0.6 | ^2.6.10 | MIT | |
| 1.0.5 | ^2.6.10 | MIT | |
| 1.0.4 | ^2.6.10 | MIT | |
| 1.0.3 | ^2.6.10 | MIT | |
| 1.0.2 | ^2.6.10 | MIT | |
| 1.0.1 | ^2.6.10 | MIT | |
| 1.0.0 | ^2.6.10 | MIT |