make the button text dynamic

This commit is contained in:
Andreas Zweili 2021-01-25 18:04:57 +01:00
parent 990f588ed5
commit 1b34a7753f
1 changed files with 10 additions and 1 deletions

View File

@ -1,7 +1,7 @@
<template>
<li>
<h2>{{ friend.name }}</h2>
<button @click="toggleDetails()">Show Details</button>
<button @click="toggleDetails()">{{ buttonDetailsText }}</button>
<ul v-if="detailsAreVisible">
<li><strong>Phone:</strong> {{ friend.phone }}</li>
<li><strong>Email:</strong> {{ friend.email }}</li>
@ -22,6 +22,15 @@ export default {
},
};
},
computed: {
buttonDetailsText() {
if (this.detailsAreVisible) {
return "Hide Details";
} else {
return "Show Details";
}
},
},
methods: {
toggleDetails() {
this.detailsAreVisible = !this.detailsAreVisible;