From 1b68fe4dfebdd34300d05b156f66dc657b7c51bb Mon Sep 17 00:00:00 2001 From: Cristiano Magro <cristiano.magro@vola.it> Date: Tue, 07 Jan 2025 16:06:55 +0100 Subject: [PATCH] fetch user input --- 10 - course project/xno-prj-cmp-01-starting-setup/src/components/learning-resource/TheResources.vue | 16 +++++++++++++++- 1 files changed, 15 insertions(+), 1 deletions(-) diff --git a/10 - course project/xno-prj-cmp-01-starting-setup/src/components/learning-resource/TheResources.vue b/10 - course project/xno-prj-cmp-01-starting-setup/src/components/learning-resource/TheResources.vue index 1d136bc..f0e74fd 100644 --- a/10 - course project/xno-prj-cmp-01-starting-setup/src/components/learning-resource/TheResources.vue +++ b/10 - course project/xno-prj-cmp-01-starting-setup/src/components/learning-resource/TheResources.vue @@ -11,7 +11,9 @@ >Add Resource</base-button > </base-card> - <component :is="selectedTab"></component> + <KeepAlive> + <component :is="selectedTab"></component> + </KeepAlive> </template> <script> @@ -53,12 +55,24 @@ provide() { return { resources: this.storedResouces, + addResource: this.addResource, }; }, methods: { setSelectedTab(tab) { this.selectedTab = tab; }, + addResource(title, description, url) { + const newResource = { + id: new Date().toISOString(), + title: title, + description: description, + link: url, + }; + + this.storedResouces.unshift(newResource); + this.selectedTab = 'stored-resources'; + }, }, }; </script> -- Gitblit v1.8.0