简体   繁体   English

将参数传递给另一个文件 JS 中的函数

[英]Pass param into function in another file JS

In my app.js I have在我的app.js我有

io.sockets.on("connection", connectSocket);

and then in a different file I have:然后在另一个文件中我有:

const connectSocket = (socket, bitlyAppURL) => {
  socket.once(AUTHENTICATED_CONNECTION_REQUEST, params => {
    connectAuthenticatedSocket(socket, params, bitlyAppURL);
  });

  socket.once("disconnect", disconnectSocket);

  socket.emit(AUTHENTICATE_YOURSELF);
};

but I'm not sure how to pass this bitlyAppURL into the function in app.js .但我不确定如何将此bitlyAppURL传递到app.js的函数中。

使用socket.on的回调:

io.sockets.on("connection", socket => connectSocket(socket, bitlyAppURL));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 js-将额外的参数传递给回调函数 - js - pass extra param to callback function Js如何调用函数并从另一个文件传递参数 - Js how call function and pass params from another file 如何调用netlify函数并在另一个js文件中传递变量? - How to call netlify function and pass variable within another js file? Angular,将泛型类型传递给另一个函数。 如何输入参数? - Angular, pass generic type into another function. How to typed param? 如何将更改的输入值作为参数传递给另一个函数 - how to pass changed input value as param to another function 如何从另一个js文件中调用函数; 如何将会话变量传递到另一个js文件 - How to call function from another js file; how to pass session variables to another js file 将函数参数传递给ngSweetAlert - Pass function param to ngSweetAlert 如何将 MVC3 模型作为 JSON 参数传递给 JS 函数? - How to pass MVC3 Model as JSON param to JS function? 如何将变量传递给一个js文件到onload function中的另一个js文件 - how to pass variable to one js file to another js file inside onload function 如何将全局变量值从js文件中的函数传递到其他文件中的另一个函数 - How to pass a global variable value from a function in a js file to another function in a different file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM