【发布时间】:2017-10-08 22:59:46
【问题描述】:
我正在尝试让 recaptcha 回调在组件中与 vue.js 一起使用。验证码本身确实有效,但不是我在 data-callback 属性中定义的回调。
我已经尝试了所有我能想到的方法,但我仍然收到 ReCAPTCHA couldn't find user-provided function: dothisthat 错误。
这是组件
<script>
function dothisthat (){
alert(312);
}
</script>
<template>
<div class="well main-well">
<h4>Captcha</h4>
<p class="small">You must complete the captcha to finish your booking.</p>
<div id="captcha-wrapper">
<div class="g-recaptcha" :data-sitekey="captchaKey" data-callback="dothisthat"></div>
</div>
</div>
</template>
<script>
function dothisthat (){
alert(123);
}
import * as filters from '../../../filters';
import Translation from '../../../Translation';
export default {
name: 'Captcha',
props: {
},
computed: {
captchaKey: function() {
return this.$store.getters.captcha;
}
},
methods: {
dothisthat: function(){
return function() {
console.log("123");
};
}
},
mounted(){
function dothisthat() {
alert(123);
}
$(function() {
function dothisthat() {
alert(123);
}
});
}
}
</script>
没有一个dothisthat 函数被调用。
我做错了什么?
【问题讨论】:
-
试试
:data-callback="dothisthat"? -
返回 ReCAPTCHA 找不到用户提供的函数:function boundFn(a) { var l = arguments.length;返回 l ? l > 1 ? fn.apply(ctx, arguments) : fn.call(ctx, a) : fn.call(ctx) }
标签: javascript vue.js recaptcha