我不是 JS 節點,并且在使用我的測試夾具(.json 文件)時遇到問題。這是我的 .json 文件:{"info": [ { "type": "person", "gender": "Male", "altUrl": "http://www.testUrl.com", "contact": { "email": { "type": "Work", "address": "[email protected]", }, "phone": { "type": "Mobile", "number": "8989898989" } } }]}在我的 .js 文件中,我有: var account = require('../../myfile.json');問題是,當我嘗試從 .json 文件訪問數據時,它總是以未定義的形式返回。我調用 .json 文件的一個例子是:console.log(account.info.gender);有沒有人知道為什么我會得到未定義的值?任何幫助將不勝感激!謝謝
從我的 .json 文件/第一次 js 節點用戶獲取未定義的值
海綿寶寶撒
2022-01-07 16:11:11