node.js全局变量? [英] node.js global variables?
本文介绍了node.js全局变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在这里询问:
node.js需要继承?
,被告知我可以通过省略var来将变量设置为全局范围。
and was told that I can set variables to the global scope by leaving out the var.
这不适用于
ie:
_ = require('underscore');
不对所需文件提供_。我可以用express的 app.set
设置,并且可以在其他地方使用。
Does not make the _ available on required files. I can set with express's app.set
and have it available elsewhere though.
有人可以确认这是应该的上班?谢谢。
Can somebody confirm that this is supposed to work? Thanks.
推荐答案
global._ = require('underscore')
这篇关于node.js全局变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文