Skip to content
Advertisement

How do I make @click of a div that is receiving looped data of an API the div popups a window showing the rest of the keys in each object in the API

JavaScript

The div with {{user.name}} when clicked I want it to show the rest of the details in the Api like user.email, user.occupation, in a new window, Api data is coming from store.

am still new to vuex.

Advertisement

Answer

Add click event listener to div with .native modifier if you are using Vue 2 or without if you are using Vue 3 (docs). In event handler function open your app in a new window with the proper route path.

JavaScript
JavaScript

Also you can append to your route an id of an instance you want to display info about (e.g. ‘mySuperApp.com/users/232344’). Then you obtain it by calling in your component $route.params.id and then retrieve info from your Vuex store by that user id.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement