[問題] node global變數問題

看板Web_Design作者 (hippo泡)時間8年前 (2017/03/11 17:59), 編輯推噓3(301)
留言4則, 2人參與, 最新討論串1/1
如果是 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

03/11 23:36, , 1F
沒被宣告的變數就是參照全域變數,你這樣做就行了
03/11 23:36, 1F

03/12 09:49, , 2F
沒辦法
03/12 09:49, 2F

03/12 16:59, , 3F
在其中一個 module 中指定 global.test = "123",其它的
03/12 16:59, 3F

03/12 17:01, , 4F
module 就能使用 test 變數了。
03/12 17:01, 4F
文章代碼(AID): #1Omyg5oD (Web_Design)
文章代碼(AID): #1Omyg5oD (Web_Design)