這里的sport有點(diǎn)莫名其妙???
? ?$.each(data, function (index, sport) {
? ? ? ? ? ? ? ? ? ? ? ? ? ? $("ul").append("<li>" + sport["name"] + "</li>");}
這里的data就是獲取到的數(shù)據(jù),可是為什么還要個sport呢?直接用data['name']不就可以了嗎?
不懂不懂?。。?/p>
? ?$.each(data, function (index, sport) {
? ? ? ? ? ? ? ? ? ? ? ? ? ? $("ul").append("<li>" + sport["name"] + "</li>");}
這里的data就是獲取到的數(shù)據(jù),可是為什么還要個sport呢?直接用data['name']不就可以了嗎?
不懂不懂?。。?/p>
2016-04-07
sport[name] 也可以寫成這樣data[index].name ?把(index,sport)中的sport去掉
比如說,data=[
{name:'小明',age:12},
{name:'小紅',age:13}
]
sport就是{name:'xx',age:xx}這樣的一項(xiàng),所以取的sport.name
data是個數(shù)組,sport是數(shù)組中的一項(xiàng)
舉報
2016-06-02
這樣好理解點(diǎn)