1 回答
TA贡献1874条经验 获得超12个赞
试试这个解决方案。
var postDocRef = db.collection('posts').doc(uid).collection('userPosts')
postDocRef.get().then(snapshot => {
setupPosts(snapshot.docs)
})
const posts = document.querySelector('.posts');
const setupPosts = (data) => {
let html = '';
data.forEach(doc => {
var docRefIDpost = docRef.id
const post = doc.data();
let li = `<li class="post">
<div class="title">${post.title}</div>
<div class="content">${post.content}</div>`;
li += (post.picURL ? `<img class="img" src="${post.picURL}">` : ``);
li += `</li><br></br>`;
html += li
})
posts.innerHTML = html;
}
添加回答
举报