简体   繁体   English

如何将值从一个 function 发送到另一个

[英]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.

相关问题 如何使用会话以外的方式将 PHP 中的值从一个页面发送到另一个页面? - How I can send value in PHP from one page to another using other than session? 如何将值从静态函数发送到另一个对象? - how would I send a value from static function to the other object? 我如何从jsonp响应中获取值并将该值设置为其他函数中的其他变量呢? - How I can get value from jsonp response and set that value too other variable in other function? 如何将一个函数的值转换为文档准备就绪? - How can I get the value from one function into document ready? 如何将表单值从一个 function 传递到另一个 function 并显示 - How to pass Form value from one function to other function and display 如何从一个 function 发送多个 API 请求 - How Can I send multiple API request from one function altogether 如何将变量的值从一个组件发送到另一个组件? (反应) - How can I send the value of a variable from one component to another? (React) 如何将钩子的值从一个 jsx 使用到另一个 - How can I use the hook's value from one jsx to other 如何将 var 值从一个 function 移动到另一个? Javascript - How to move var value from one function to the other? Javascript 如何将php参数从一个函数发送到另一个函数(function.php)? - How to send php parameter from one function to other (function.php)?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM