【发布时间】:2022-01-08 13:19:53
【问题描述】:
在我的网站中,我列出了用户可以在其上分享他们的 cmets 的电影和电视剧。用户可以添加 cmets,但是在接收 cmets 时,会返回一个未定义的值。 (我正在尝试从movieComment 中获取cmets。movieComment 存储电影的cmets)
var show = qs["movieId"];
/* show variable is giving my movie's ID and it is 1 */
btnComment.addEventListener('click', (e) => {
var movieComment = document.getElementById('textComment').value;
push(child(firebaseRef, 'Movies/' + show + '/movieComment/'), movieComment) {
movieComment: movieComment
};
});
function AddItemsToTable2(comment) {
const comments = `
<td>Alan Smith</td>
<td><i class="fa fa-star" style="color:rgb(91, 186, 7)"></i></td>
<td>${comment}<h6>[May 09, 2016]</h6></td>
`;
html = comments;
body2.innerHTML += html;
}
}
function AddAllItemsToTable2(TheComments) {
body2.innerHTML = "";
TheComments.forEach(element => {
AddItemsToTable2(element.movieComment);
});
}
function getAllDataOnce2() {
var show = qs["movieId"];
get(child(firebaseRef, 'Movies/' + show + '/movieComment')).then((snapshot) => {
var comments = [];
comments.push(snapshot.val());
console.log(comments);
AddAllItemsToTable2(comments);
});
}
window.onload = (event) => {
getAllDataOnce2();
};
Console.log(电影)
未定义错误:
【问题讨论】:
-
请提供调试信息。
标签: javascript firebase firebase-realtime-database