【发布时间】:2021-12-14 09:39:42
【问题描述】:
我正在使用 Facebook 登录,并且我正在为用户显示加载进度,直到我收到 Facebook 的回复以进行身份验证。 但是我曾经像this.progress = false一样隐藏进度条但是这个变量在窗口函数中是未定义的。
我的代码:
initFacebook() {
this.progress=true
window.fbAsyncInit = function() {
window.FB.init({
appId: "MY-APP-ID", //You will need to change this
cookie: true, // This is important, it's not enabled by default
version: "v2.6",
status: false,
});
window.FB.login(function(response) {
if (response.status === 'connected'){
window.FB.api('/me?fields=id,name,email', function(response) {
console.log( response) // it will not be null ;)
})
} else {
console.log("User cancelled login or did not fully authorize.")
}
},
{scope: 'public_profile,email'}
);
this.progress = false
console.warn(this.progress)
};
},
在收到 Facebook 的所有回复后,我无法设置 this.progress = false。
我在 console.log(this.progress) 变量时遇到错误。
错误:
Login.vue?7463:175 undefined
身份验证检查完成后,如何将 this.progress 变量设置为 false?
【问题讨论】:
-
嘿,您可能想使用箭头函数 () => 而不是函数 () {}
标签: javascript vue.js vuejs2 vuejs3