【问题标题】:what is the best way to pass variables from a node.js file to another?将变量从 node.js 文件传递​​到另一个文件的最佳方法是什么?
【发布时间】:2017-07-17 14:04:51
【问题描述】:

我进行了研究,但没有找到我想要的。

例如,我有一个带有代码的 Node.js 文件:

var pseudo = req.body.pseudo;
var activation_link = generate_random_key();
message = ?
send_mail(destinataire, "subject", message);

和另一个独立的 node.js 文件:

var message = Hello {{pseudo}}. Welcome to my website. The link of activation to activate your account is: {{activation_link}}

你可以猜到,我想将伪变量从第一个文件传递到第二个文件,并且还将消息变量从 file2 传递到 file1。

问题:最合适的方法是什么?

感谢您的帮助。

【问题讨论】:

    标签: node.js command-line-arguments ipc


    【解决方案1】:

    process.argv 应该可以帮助您。 完成此操作后,用于进程间通信this will help you

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-04-22
      • 2016-02-17
      • 1970-01-01
      • 2023-03-17
      • 1970-01-01
      • 2014-07-02
      • 1970-01-01
      相关资源
      最近更新 更多