Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
DMD-4470/final/src/views/Home.vue
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
51 lines (39 sloc)
929 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div class="home"> | |
<ul id="postList"> | |
<li v-for="(post, name, index) in posts" :key=index>{{ post.message }}</li> | |
</ul> | |
<!-- <PlaceholderTweets msg="still works?"/> --> | |
</div> | |
</template> | |
<script> | |
// @ is an alias to /src | |
// import PlaceholderTweets from '@/components/PlaceholderTweets.vue' | |
export default { | |
name: 'home', | |
data: function(){ | |
return { | |
posts: [] | |
} | |
}, | |
components: { | |
// PlaceholderTweets | |
}, | |
methods: { | |
getPosts(){ | |
db.collection("posts").get().then(querySnapshot => { | |
querySnapshot.forEach( doc => { | |
// doc.data() is never undefined for query doc snapshots | |
console.log(doc.id, " => ", doc.data()); | |
this.posts.unshift(doc.data()) | |
}); | |
}); | |
} | |
}, | |
// This runs when the page loads | |
mounted() { | |
// console.log(db); | |
this.getPosts(); | |
} | |
}; | |
</script> |