From 6d1f81d23add8ae071ee197e46820ee2dffac300 Mon Sep 17 00:00:00 2001 From: Andreas Zweili Date: Sat, 4 Sep 2021 11:57:57 +0200 Subject: [PATCH] solve the task with a ref object --- .../src/App.vue | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/2021-09-04_composition-assignment-1-problem/src/App.vue b/2021-09-04_composition-assignment-1-problem/src/App.vue index b704868..3ec6604 100644 --- a/2021-09-04_composition-assignment-1-problem/src/App.vue +++ b/2021-09-04_composition-assignment-1-problem/src/App.vue @@ -2,7 +2,7 @@

My Course Goal

-

{{ courseGoal }}

+

{{ courseGoal }}

@@ -18,16 +18,25 @@ import { ref } from 'vue'; export default { setup() { const courseGoal = 'Something is written here'; - const showGoal = ref(false); + //const showGoal = ref(false); + const Goal = ref({ + visibility: false + }); + // ref way + //function toggleGoal() { + // showGoal.value = !showGoal.value; + // console.log(showGoal.value); + //} + + // ref object way function toggleGoal() { - showGoal.value = !showGoal.value; - console.log(showGoal.value); + Goal.value.visibility = !Goal.value.visibility; } return { courseGoal, - showGoal, + Goal, toggleGoal }; }