javascript - 我在 Facebook 登录页面中收到“未捕获(承诺)类型错误:无法重新定义属性:cookie”js 错误。有人可以帮忙吗?
问题描述
我在 Facebook 登录页面中收到“未捕获(承诺)类型错误:无法重新定义属性:cookie”js 错误。有人可以帮忙吗?我找不到导致错误的原因,但是当我从 js 文件中删除以下代码时,错误消失了。
这是我初始化facebook jdk的代码,
function statusChangeCallback(response) {
if (response.status === 'connected') { // Logged into your webpage and Facebook.
var fbAccessToken = response.authResponse.accessToken;
console.log("statuscallback: " + fbAccessToken);
verify_user(fbAccessToken, "facebook");
} else {
}
}
function checkFBLoginState() {
FB.getLoginStatus(function (response) {
statusChangeCallback(response);
});
}
window.fbAsyncInit = function () {
//FB JavaScript SDK configuration and setup
FB.init({
appId: '***MYAPPID***',
cookie: true,
xfbml: true,
version: 'v10.0'
});
FB.getLoginStatus(function (response) { // Called after the JS SDK has been initialized.
statusChangeCallback(response); // Returns the login status.
});
};
(function (d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) { return; }
js = d.createElement(s); js.id = id;
js.src = "https://connect.facebook.net/tr_TR/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
function fbLogout() {
FB.logout(function (response) {
// Person is now logged out
});
}
这是我在控制台上遇到的错误:
Uncaught (in promise) TypeError: Cannot redefine property: cookie at Function.defineProperty (<anonymous>) at defineProperty (<anonymous>:814:17) at blockCookies (<anonymous>:1235:6) at init$7 (<anonymous>:1326:10) at <anonymous>:923:14 at Array.forEach (<anonymous>) at Object.initProtections (<anonymous>:921:26)
这是引发错误的以下代码:
// TODO make rollup aware of this so it can tree shake
const mozProxies = 'wrappedJSObject' in window;
function defineProperty (object, propertyName, descriptor) {
if (mozProxies) {
const usedObj = object.wrappedJSObject;
const UsedObjectInterface = window.wrappedJSObject.Object;
const definedDescriptor = new UsedObjectInterface();
['configurable', 'enumerable', 'value', 'writable'].forEach((propertyName) => {
// TODO check if value is complex and export it if so.
if (propertyName in descriptor) {
definedDescriptor[propertyName] = descriptor[propertyName];
}
});
['get', 'set'].forEach((methodName) => {
if (methodName in descriptor) {
exportFunction(descriptor[methodName], definedDescriptor, { defineAs: methodName });
}
});
UsedObjectInterface.defineProperty(usedObj, propertyName, definedDescriptor);
} else {//error thrown
Object.defineProperty(object, propertyName, descriptor);
}
}
解决方案
推荐阅读
- java - Tomcat:maxConnections、maxThreads、acceptCount 设置和大型 http 请求
- c# - 当我使用 AsParallel 时是否有必要使用线程安全的方法?
- r - 在函数参数中使用字母
- python-3.x - [Index(['a', 'c'], dtype='object')] 都没有在 [columns] 错误中
- azure - Azure cosmos db 存储过程不起作用
- flutter - onGenerateRoute 多次调用
- awk - 使用 awk 就地编辑时如何刷新输出?
- dialogflow-es - 自定义 Dialogflow Fulfillment 响应
- python - windows上使用sublime text 3编辑Anaconda python代码
- amazon-web-services - 如果用于 S3 加密的 AWS 密钥丢失会怎样?