我正在尝试在我的 react 网站上添加使用 FB 登录。
FB.init({
appId : app_id,
cookie : true,
xfbml : true,
version : 'v5.0'
});
其次是FB.getLoginStatus(({status}) => {
if (status === 'connected') {
FB.logout();
}
FB.login((response) => {
if (response.authResponse) {
const {authResponse: {accessToken}} = response;
onSuccess(accessToken);
} else {
onError({error: 'popup_closed_by_user'});
}
}, {scope: 'email'});
})
但它第一次打开弹出窗口(当 getLoginStatus
不是 connected
时),然后第二次在控制台上显示错误Uncaught b { innerError: undefined, message: "Expression is of type undefined, not function" }
经过进一步调查,我发现错误发生在行 FB.logout()
时。叫做。我可能做错了什么?
注意 直到昨天,相同的代码仍在工作。
最佳答案
好像是 FB.logout
现在需要参数:cb
.
https://developers.facebook.com/docs/reference/javascript/FB.logout/
不确定它何时成为强制性的,但没有它就无法工作。
关于javascript - JS 项目中的 FB.logout 给出错误 "Expression is of type undefined, not function",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67196231/