作者stevekevin10 (hippo泡)
看板Web_Design
標題[問題] node global變數問題
時間Sat Mar 11 17:59:30 2017
如果是
global.test = xxx
那我在我的各module中使用
global.test是ok的
但我想要能讓每一個module直接打test就有該值(除非該module下有重新指派該變數)
請問該如何做呢?
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 111.251.143.233
※ 文章網址: https://www.ptt.cc/bbs/Web_Design/M.1489226373.A.C8D.html
推 eight0: 沒被宣告的變數就是參照全域變數,你這樣做就行了 03/11 23:36
推 s25g5d4: 沒辦法 03/12 09:49
推 eight0: 在其中一個 module 中指定 global.test = "123",其它的 03/12 16:59
→ eight0: module 就能使用 test 變數了。 03/12 17:01