Skip to content

Commit

Permalink
Complete module5
Browse files Browse the repository at this point in the history
  • Loading branch information
butzopower committed Oct 4, 2018
1 parent 8b467bb commit 1815b88
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
29 changes: 29 additions & 0 deletions src/components/BookForm.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<template>
<form v-on:submit.prevent="bookSubmit(bookTitle, bookAuthor)" class="" action="#" method="post">
<input type="text" name="title" value="" placeholder="Book Title" v-model="bookTitle">
<input type="text" name="author" value="" placeholder="Book Author" v-model="bookAuthor">
<button type="submit" name="button">Add Book</button>
</form>
</template>

<script>
export default {
name: 'BookForm',
props: ['books'],
data() {
return {
bookTitle: '',
bookAuthor: ''
}
},
methods: {
bookSubmit(bookTitle, bookAuthor) {
this.$emit('addBook', bookTitle, bookAuthor)
}
}
};
</script>

<style scoped>
</style>
10 changes: 9 additions & 1 deletion src/components/BookList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@
<ul>
<book-item v-for="book in books" :book="book"></book-item>
</ul>

<book-form @addBook="appendBook"></book-form>
</div>
</template>

<script>
import BookItem from './BookItem';
import BookForm from './BookForm';
export default {
name: "BookList",
components: { BookItem },
components: { BookItem, BookForm },
data() {
return {
title: "All Books",
Expand All @@ -23,6 +26,11 @@
]
}
},
methods: {
appendBook(bookTitle, bookAuthor) {
this.books.push({ title: bookTitle, author: bookAuthor });
}
}
}
</script>

Expand Down

0 comments on commit 1815b88

Please sign in to comment.