xlsdg / react-geetest Goto Github PK
View Code? Open in Web Editor NEWA Geetest component for React
Home Page: https://docs.geetest.com/install/deploy/client/web
License: MIT License
A Geetest component for React
Home Page: https://docs.geetest.com/install/deploy/client/web
License: MIT License
initGeetest({
// 省略配置参数
}, function (captchaObj) {
// 省略其他方法的调用
// 这里调用了 onSuccess 方法,该方法介绍见下文
captchaObj.onSuccess(function () {
var result = captchaObj.getValidate();
// ajax 伪代码
ajax('/api/gt-validate', {
geetest_challenge: result.geetest_challenge,
geetest_validate: result.geetest_validate,
geetest_seccode: result.geetest_seccode,
username: 'xxx',
password: 'xxx'
// 其他服务端需要的数据,比如登录时的用户名和密码
}, function (data) {
// 根据服务端二次验证的结果进行跳转等操作
if (data.status === 'fail') {
alert('用户名或密码错误,请重新输入并完成验证');
captchaObj.reset(); // 调用该接口进行重置
}
});
});
});
官网地址是这样额
可是我看你的代码里面
onSuccess: function onSuccess() {},
onError: function onError() {},
onClose: function onClose() {},
ins.appendTo(that.dom);
ins.onReady(onReady);
ins.onSuccess(function() {
return onSuccess(ins.getValidate(), ins);
});
ins.onError(onError);
ins.onClose(onClose);
并没有在onError给我仍和参数
请问一下,product为 bind的时候,怎么触发 verify属性呢?
react-geetest 版本是 4.0.3
import React from 'react';
import { request } from 'umi';
import Geetest from 'react-geetest';
export default () => {
const gt = '0cb2301a6474506db6cabd271ae3976d';
const challenge = 'c1caf3daf3feb384161de77ddc9bdf2c';
const onSuccess = (isSuccess: any) => {
const { geetest_challenge, geetest_seccode, geetest_validate } = isSuccess;
console.log(isSuccess, '每次都是相同的');
};
return (
<div>
<Geetest
gt={gt}
challenge={challenge}
offline
product={"float"}
newCaptcha
nextWidth="90%"
bgColor="#000"
onSuccess={onSuccess}
/>
</div>
);
}
初始化传了gt, challenge, onSuccess 进去, 控制台报错了, 说是 ins.onClose is not a function , 是我调用的问题吗 ? 我看你设置了默认值啊
报错。出现这个问题
Geetest.jsx:120 Uncaught TypeError: ins.onRefresh is not a function
at Geetest._load (Geetest.jsx:120)
at Geetest.jsx:104
at init (geetest.js:256)
at geetest.js:276
at geetest.js:168
at geetest.js:110
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.