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; }, }, };