From 708ab00477a8d007709e1dee6eacb8cbbbf57757 Mon Sep 17 00:00:00 2001 From: Andreas Zweili Date: Mon, 25 Jan 2021 23:05:01 +0100 Subject: [PATCH] change isFavorite to a boolean --- .../src/components/FriendContact.vue | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/vue-cli-01-a-new-vue-project/src/components/FriendContact.vue b/vue-cli-01-a-new-vue-project/src/components/FriendContact.vue index 0efdacc..3111f11 100644 --- a/vue-cli-01-a-new-vue-project/src/components/FriendContact.vue +++ b/vue-cli-01-a-new-vue-project/src/components/FriendContact.vue @@ -27,12 +27,9 @@ export default { required: true, }, isFavorite: { - type: String, + type: Boolean, required: false, - default: "0", - validator: function(value) { - return value === "0" || value === "1"; - }, + default: false, }, }, data() { @@ -50,7 +47,7 @@ export default { } }, isFavoriteText() { - if (this.friendIsFavorite === "1") { + if (this.friendIsFavorite) { return "(Favorite)"; } else { return ""; @@ -62,11 +59,7 @@ export default { this.detailsAreVisible = !this.detailsAreVisible; }, toggleFavorite() { - if (this.friendIsFavorite === "1") { - this.friendIsFavorite = "0"; - } else { - this.friendIsFavorite = "1"; - } + this.friendIsFavorite = !this.friendIsFavorite; }, }, };