Cristiano Magro
2024-12-28 7b062dd850df16c29aec4496882fc8e751ad5bac
commit | author | age
f31b9e 1 <template>
CM 2     <li>
7b062d 3         <h2>{{ name }} {{ friendIsFavorite === "1" ? '(Favorite)' : '' }}</h2>
f31b9e 4         <button @click="toggleDetails">
CM 5             {{ detailsAreVisible ? 'Hide' : 'Show' }} Details
7b062d 6         </button>
CM 7
8         <button @click="toggleFavorite">
9             Toggle favorite
f31b9e 10         </button>
CM 11         <ul v-if="detailsAreVisible">
498b47 12             <li><strong>Phone:</strong> {{ phoneNumber }}</li>
CM 13             <li><strong>Email:</strong> {{ emailAddress }}</li>
f31b9e 14         </ul>
CM 15     </li>
16 </template>
17
18 <script>
19 export default {
498b47 20     props: [
CM 21         'name',
22         'phoneNumber',
23         'emailAddress',
7b062d 24         'isFavorite'
498b47 25     ],
f31b9e 26     data() {
CM 27         return {
28             detailsAreVisible: false,
29             friend: {
30                 id: "manuel",
31                 name: "Manuel Lorenz",
32                 phone: "01234 5678 991",
33                 email: "manuel@localhost.com",
7b062d 34             },
CM 35             friendIsFavorite: this.isFavorite,
f31b9e 36         }
CM 37     },
38     methods: {
39         toggleDetails() {
40             this.detailsAreVisible = !this.detailsAreVisible;
41         },
7b062d 42         toggleFavorite() {
CM 43             if (this.friendIsFavorite === '1') {
44                 this.friendIsFavorite = '0';
45             } else {
46                 this.friendIsFavorite = '1';
47             }
48         },
f31b9e 49     },
CM 50 };
51 </script>