This repository has been archived on 2021-09-06. You can view files and clone it, but cannot push or open issues or pull requests.
vuejs_course/vue-cli-01-a-new-vue-project/src/components/FriendContact.vue

36 lines
841 B
Vue
Raw Normal View History

2021-01-25 18:00:09 +01:00
<template>
<li>
2021-01-25 18:32:18 +01:00
<h2>{{ name }}</h2>
2021-01-25 18:04:57 +01:00
<button @click="toggleDetails()">{{ buttonDetailsText }}</button>
2021-01-25 18:00:09 +01:00
<ul v-if="detailsAreVisible">
2021-01-25 18:32:18 +01:00
<li><strong>Phone:</strong> {{ phoneNumber }}</li>
<li><strong>Email:</strong> {{ emailAddress }}</li>
2021-01-25 18:00:09 +01:00
</ul>
</li>
</template>
<script>
export default {
2021-01-25 18:32:18 +01:00
props: ["name", "emailAddress", "phoneNumber"],
2021-01-25 18:00:09 +01:00
data() {
return {
detailsAreVisible: false,
};
},
2021-01-25 18:04:57 +01:00
computed: {
buttonDetailsText() {
if (this.detailsAreVisible) {
return "Hide Details";
} else {
return "Show Details";
}
},
},
2021-01-25 18:00:09 +01:00
methods: {
toggleDetails() {
this.detailsAreVisible = !this.detailsAreVisible;
},
},
};
</script>