我的JSON格式是
{
"Featured" : {
"project" : [ {
"artist" : "stuff",
"artistEPK" : "artistsownepk.pdf",
"author" : "john queue author",
"date" : "7/28/2016",
"fullScreenImg" : "https://firebasestorage.googleapis.com/v0/b/wallplay-a8440.appspot.com/o/Screen%20Shot%202016-06-08%20at%2012.00.06%20PM.png?alt=media&token=1df5d60d-808c-48bb-a591-e005f82e4687",
"linksToMedia" : [ "" ],
"linksToPress" : [ "" ],
"location" : "10 Main Street",
"mainImg" : "https://firebasestorage.googleapis.com/v0/b/wallplay-a8440.appspot.com/o/Screen%20Shot%202016-06-08%20at%2012.00.06%20PM.png?alt=media&token=1df5d60d-808c-48bb-a591-e005f82e4687",
"pressImgs" : [ "https://firebasestorage.googleapis.com/v0/b/wallplay-a8440.appspot.com/o/Screen%20Shot%202016-06-08%20at%2012.00.06%20PM.png?alt=media&token=1df5d60d-808c-48bb-a591-e005f82e4687", "https://firebasestorage.googleapis.com/v0/b/wallplay-a8440.appspot.com/o/Screen%20Shot%202016-06-08%20at%2012.00.06%20PM.png?alt=media&token=1df5d60d-808c-48bb-a591-e005f82e4687", "https://firebasestorage.googleapis.com/v0/b/wallplay-a8440.appspot.com/o/Screen%20Shot%202016-06-08%20at%2012.00.06%20PM.png?alt=media&token=1df5d60d-808c-48bb-a591-e005f82e4687" ],
"pressRelease" : "projectpressrelease.pdf",
"projectImgs" : [ "https://firebasestorage.googleapis.com/v0/b/wallplay-a8440.appspot.com/o/Screen%20Shot%202016-06-08%20at%2012.00.06%20PM.png?alt=media&token=1df5d60d-808c-48bb-a591-e005f82e4687", "https://firebasestorage.googleapis.com/v0/b/wallplay-a8440.appspot.com/o/Screen%20Shot%202016-06-08%20at%2012.00.06%20PM.png?alt=media&token=1df5d60d-808c-48bb-a591-e005f82e4687", "https://firebasestorage.googleapis.com/v0/b/wallplay-a8440.appspot.com/o/Screen%20Shot%202016-06-08%20at%2012.00.06%20PM.png?alt=media&token=1df5d60d-808c-48bb-a591-e005f82e4687" ],
"projectSubheader" : "subheader of project",
"projectTitle" : "title of project",
"projectURL" : "",
"soundFile" : [ "" ],
"text" : "here there would be a text for james turell",
"videoURL" : "www.youtube.com/james-m-video"
} ]
}
}
所以当我进入我的Firebase并尝试使用
提取信息时var ul = document.getElementById("featured_links");
featuredRef.orderByChild("date").on("child_added", function(snapshot) {
console.log("inside ref");
var links = snapshot.val().fullScreenImg;
var li = document.createElement("li");
var img = document.createElement("img");
img.setAttribute("src" , links);
li.appendChild(img);
ul.appendChild(li);
console.log(links);
});
其中,特色链接只是我的html文件中的一个ul,我试图放入。这个新的JSON格式比我的另一个大很多,但是另一个没有读取文件的问题。
其他JSON:
{
"Featured" : {
"Link2" : {
"isEmbed" : false,
"priority" : 4,
"tag" : "yahoo people",
"url" : "https://s3.amazonaws.com/hagshs8282n23/image7.jpg"
}
}
}
据我所知,featuredRef.on("child_added", function(snapshot){
不是for循环,因为它不会打印"在ref"当它到达它。目前只有一个数据输入,所以我不知道为什么我遇到这样的问题。