[英]how can I send a value from one function to the other
I have a function that checks whether the user is logged in or not and another that protects the routes and I wanted the function's true or false value to check whether the user is logged in or not to be sent to "const authentication" in any way to do it?我有一个 function 用于检查用户是否登录,另一个用于保护路由,我希望该函数的 true 或 false 值检查用户是否登录以任何方式发送到“const authentication”去做吧? I thank anyone who can help
我感谢任何可以提供帮助的人
firebase.auth().onAuthStateChanged((user) => {
if (user) {
this.login = true /// types this //// this value
console.log('logged')
} else {
this.login = false /// or this values
console.log('nologin');
}
});
const authentication={
isLoggedIn: this.login, //// go here
onAuthentication(){
this.isLoggedIn=true;
},
getLogInStatus(){
return this.isLoggedIn;
}
}
var globalVariable;
function function1()
{
//set a value
globalVariable=12;
function2();
}
function function2()
{
//local gets that same value
var local = globalVariable;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.