| | |
| | | <template> |
| | | <li> |
| | | <h2>{{ name }} {{ friendIsFavorite ? '(Favorite)' : '' }}</h2> |
| | | <h2>{{ name }} {{ isFavorite ? '(Favorite)' : '' }}</h2> |
| | | <button @click="toggleDetails"> |
| | | {{ detailsAreVisible ? 'Hide' : 'Show' }} Details |
| | | </button> |
| | |
| | | // 'isFavorite' |
| | | // ], |
| | | props: { |
| | | id:{ |
| | | title: String, |
| | | required: true |
| | | }, |
| | | name: { |
| | | title: String, |
| | | required: true |
| | |
| | | data() { |
| | | return { |
| | | detailsAreVisible: false, |
| | | friendIsFavorite: this.isFavorite, |
| | | } |
| | | }, |
| | | methods: { |
| | |
| | | this.detailsAreVisible = !this.detailsAreVisible; |
| | | }, |
| | | toggleFavorite() { |
| | | this.friendIsFavorite = !this.friendIsFavorite; |
| | | // this.friendIsFavorite = !this.friendIsFavorite; |
| | | this.$emit('toggle-favorite', this.id); |
| | | }, |
| | | }, |
| | | }; |