显示 JSON 对象

尝试在 javascript 中显示人员变量的各个元素在控制台中显示未定义


<script>

var staff = {"stdinfo" :{"si": "HH01", "sn":"DAVE BAN", "sc":"HGT 1 ", "scid":"44"},"stdinfo1" :{"si": "HH16", "sn":"DEOR ORIE MAR", "sc":"JHT 3", "scid":"31"}};

</script>

console.log(staff.stdinfo0.si)显示未定义。我究竟做错了什么?


呼啦一阵风
浏览 142回答 1
1回答

皈依舞

您将 stdinfo 与 stdinfo0 混淆,它缺少大括号,并且有一个额外的".var staff = {&nbsp; "stdinfo0": {"si": "HH01", "sn":"DAVE BAN", "sc":"HGT 1 ", "scid":"44"},&nbsp; "stdinfo1": {"si": "HH16", "sn":"DEOR ORIE MAR", "sc":"JHT 3", "scid":"31"}};
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript