From c4371db9541bc6463d58193f9a60542e35cc3204 Mon Sep 17 00:00:00 2001 From: Cristiano Magro <cristiano.magro@vola.it> Date: Sat, 28 Dec 2024 22:51:57 +0100 Subject: [PATCH] binding dei dati in un ciclo for --- 07 - development setup/vue-cli-01-a-new-vue-project/src/components/FriendContact.vue | 24 +++++++----------------- 1 files changed, 7 insertions(+), 17 deletions(-) diff --git a/07 - development setup/vue-cli-01-a-new-vue-project/src/components/FriendContact.vue b/07 - development setup/vue-cli-01-a-new-vue-project/src/components/FriendContact.vue index e01781a..3c5a041 100644 --- a/07 - development setup/vue-cli-01-a-new-vue-project/src/components/FriendContact.vue +++ b/07 - development setup/vue-cli-01-a-new-vue-project/src/components/FriendContact.vue @@ -1,6 +1,6 @@ <template> <li> - <h2>{{ name }} {{ friendIsFavorite === "1" ? '(Favorite)' : '' }}</h2> + <h2>{{ name }} {{ friendIsFavorite ? '(Favorite)' : '' }}</h2> <button @click="toggleDetails"> {{ detailsAreVisible ? 'Hide' : 'Show' }} Details </button> @@ -37,24 +37,18 @@ required: true }, isFavorite: { - title: String, + title: Boolean, required: false, - default: '0', - validator: function (value) { - return value === '1' || value === '0'; - } + default: false, + // validator: function (value) { + // return value === '1' || value === '0'; + // } }, }, data() { return { detailsAreVisible: false, - friend: { - id: "manuel", - name: "Manuel Lorenz", - phone: "01234 5678 991", - email: "manuel@localhost.com", - }, friendIsFavorite: this.isFavorite, } }, @@ -63,11 +57,7 @@ this.detailsAreVisible = !this.detailsAreVisible; }, toggleFavorite() { - if (this.friendIsFavorite === '1') { - this.friendIsFavorite = '0'; - } else { - this.friendIsFavorite = '1'; - } + this.friendIsFavorite = !this.friendIsFavorite; }, }, }; -- Gitblit v1.8.0