-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added v-model support #53
base: master
Are you sure you want to change the base?
Conversation
@@ -150,13 +158,16 @@ export default { | |||
const token = this.hcaptcha.getResponse(this.widgetId); | |||
const eKey = this.hcaptcha.getRespKey(this.widgetId); | |||
this.$emit('verify', token, eKey); | |||
this.$emit('input', token); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
v-model
would allow 2way binding which I believe would not make sense for the component.
One solution could be to listen to the verify
and expire
events and bind the token to a local data in your parent component. e.g.
<h-captcha
...
@verify="(token) => {hCaptchaToken = token}"
@expire="hCaptchaToken =null"
/>
// use hCaptchaToken for "required" in "vee-validate"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although the component doesn't accept the token as input, I think using v-model
would make it simpler to use. Another alternative that would solve the same problem would be to use token.sync
instead of v-model
. Thus, it would not be necessary to create event-listeners and callbacks in the component call
}, | ||
onChallengeExpired() { | ||
// vue3 will transform this `camelCase` event name into `kebab-case` | ||
this.$emit('challengeExpired'); | ||
this.$emit('input', null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a challenge expires the token
status does not change.
Now it is possible to get the token using
v-model
and also validate it with vee-validate with therequired
rule for example.