gpt4 book ai didi

javascript - 获取引用错误: appearance is not defined

转载 作者:行者123 更新时间:2023-12-02 22:24:27 30 4
gpt4 key购买 nike

我正在尝试访问 super 英雄 api,但对于某些数据,它一直显示数据未定义。

 var html = "";
$.each(data.results,function(i,results){
html += "<li> first appearance: " + results.biography.first-appearance +"</li>";
// it is not showing anything with a "-" in but the rest are working fine

})
$("#Results").html(html);

最佳答案

就像需要引用带有连字符的对象键一样,当您访问该键时,您需要使用带引号的方括号表示法:

const a = [{ biography: 'a', 'first-appearance': 'b' }];

console.log(a[0]['first-appearance'])

关于javascript - 获取引用错误: appearance is not defined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59112057/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com