Using v-for to show the values of an object in Vuetify

I am currently developing a function in vuejs that allows users to select tables from a database, with the columns' names automatically appearing in a v-list-item component. However, I am facing difficulty in displaying these column names effectively.

Here is the code snippet I am using:

<v-list-item v-for="(item,index) in this.columns" :key="index">
  <v-list-item v-for="ved in item" :key="ved.id">
    <v-list-item-content>
      <v-list-item-title >{{ved}}</v-list-item-title>
    </v-list-item-content>
  </v-list-item>
</v-list-item>

<script>
  export default {
    data() {
      return {
        columns:{},
      };
    },
  }
</script>

In order to keep the code clean, I have omitted the methods and other variables.

For instance, if I select 2 tables from the database where one table has only 1 column and the other has 3 columns, the current output from the code looks like this:

id //column of the first table

name, last_name, email // columns of the second table

However, I want the columns of the second table to be displayed separately instead of all in one line separated by commas. What I desire is as follows (without the numbers):

  1. id //first column
  2. name //second column
  3. last_name
  4. email

This is what I receive from the axios request:

[ [ "id" ], [ "name", "last_name", "email" ] ]

Answer №1

To simplify the process, you can consider the two arrays as a list and view the items within them as list-items

<v-list v-for="(item, index) in columns" :key="index">
    <v-list-item v-for="ved in item" :key="ved.id">
      <v-list-item-content>
        <v-list-item-title>{{ ved }}</v-list-item-title>
      </v-list-item-content>
    </v-list-item>
</v-list>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

It's incredibly frustrating when the Facebook like button is nowhere to be found

Currently, I am in the process of developing a website for a local bakery and have decided to incorporate a Facebook like button on the homepage. After visiting developers.facebook, I proceeded to copy and paste the code provided. It appears that there use ...

Ajax request experiencing 500 Internal Server Error. Uncertain about the source of the issue

I'm encountering a 500 Internal Server Error and I'm struggling to pinpoint the root cause of the issue. The purpose of this request is to delete a comment with a specific id from the database. The id is passed through a hidden input field. Below ...

Compatibility of Nuxt with Internet Explorer (version 9)

After running the command npx create-nuxt-app xxx to create a demo, I encountered an issue when trying to launch it in ie9 - it kept refreshing infinitely. Surprisingly, I didn't make any changes to the configuration. Upon scouring through various do ...

Converting Promises to Observables

Struggling with the syntax as I delve into learning Angular, I need to transform a promise into an Observable. Let me share what I've encountered: In the function getCountries (subscribed by another utility), there is a call required to fetch a list ...

Horizontally position the main word from the D3-WordCloud in the center

I am working on a WordCloud project and have utilized code from Jason Davies D3-JavaScript-WordCloud Example, which can be found at this link. The majority of the code I have used is from a helpful tutorial in German by Lars Ebert, available at this URL. ...

Is it possible to use multiple routes in the same page with Vue-router?

In the process of developing a Vue-based web application that utilizes vue-router in history mode, everything was functioning smoothly for navigating between various pages. However, a new request has been made to open certain pages within a virtual dialogu ...

Issue with uploading media on Wordpress: "Unfortunately, an error occurred during the upload process. Please attempt again at a later time."

Often times, when trying to upload media from the front-end, I encounter this issue: An error occurred during the upload process It seems like the error occurs sporadically, making it even more challenging to troubleshoot. Sometimes, when logging in fo ...

Retrieve information from a watcher through a Vuex getter

I am working with a namespace module that has a getter method called allItems(), which is used to retrieve an array of values from a normalized state. ... getters: { allItems(state, getters, { entities }) { return state.items.map(function ...

Create a new column in Material UI Grid by adding an empty div element instead of using padding

I'm currently getting acquainted with Material UI Grid and I am interested in adding an empty column (a blank space on the right of the first element) without utilizing padding. How can this be achieved? Here's a snippet of the code being discus ...

Leverage arrays within a personalized filtering system

I have created an array with the structure shown below... $scope.myArr = [arg1, arg2]; Now, I am interested in developing a custom filter that will accept this array as input and compare it to another array. For instance, I intend to use it in the follow ...

When using Google Maps Autocomplete, always make sure to input the full state name instead of just the state

Utilizing the Google Maps autocomplete API, we have enabled our customers to search for locations in the format of city, state, country. The functionality is effective overall, but a recurring issue arises when searching for cities, such as 'Toronto&a ...

struggling to transfer information from JavaScript to Jade within the Node.js environment

Currently, I am retrieving a row from a Cassandra table called "emp". My objective is to pass the data retrieved from the JavaScript file to a Jade file in order to display this information on the user interface. In my JavaScript function: router.get(&a ...

Using JavaScript to Capture a Webpage Element as an Image

Although this question has been asked in the past, I am hoping for updated information since all the answers are from a few years ago. While searching, I came across https://github.com/apollolm/phantasm, which seems to be exactly what I need. However, it ...

VueCropper fails to load properly

After attempting to incorporate VueCropper into my Component, I encountered a few issues: The sourceImg is displayed, but there is no cropbox or preview. When I examine console.log(this.$refs) and console.log(this.$refs.cropper), the results seem contrad ...

Exploring the world of HighCharts

I am trying to use Highcharts to calculate and visualize the magnitude of a complex number. Currently, my code is displaying the real and imaginary values separately on the graph. However, I seem to be facing issues with the "For loop" that I implemented ...

Looping through jQuery, I am adding divs, but frustratingly I can only insert text into the initial div created. Why

var numPills = 3 for(var i=0; i< numPills; i++){ //var currentPill = JUser.pill1.; $(".col-r-in").append( $('<div/>') .attr("id", "medsProgress") .addClass("roundedBar") ); $('#medsProgress').append( $('<div/>&apo ...

Utilizing Angular's ng-Grid with Promises

My current setup involves fetching a JSON file through a service to serve as the data source for my grid. The service successfully fetches the data, and the grid renders its basic layout correctly. However, there seems to be an issue with populating the gr ...

How to properly import components and CSS in Vue.js for optimized performance

As a beginner in vue.js, I find one particular concept to be quite confusing. Can someone help clarify the difference between importing a vue.js "component" and a CSS file? For example, when considering bootstrap and vue-bootstrap, do I need both? Just o ...

Is it a glitch or intentional design in Vue's template vslots feature?

I have noticed that some of my computed properties do not execute when they access the same data. To illustrate, consider this basic example: <template v-for="item in foo" v-slot:['sameSlot`]="{sameBlah}"> {{ JSON.stringify ...

Connect parent-child models with checkboxes

Currently, I am working on an application where I need to link checkboxes for a role-based menu. The challenge lies in dealing with parent-child checkboxes and ensuring that the values of checkboxes are checked based on user input 1, 1.1, 1.2, 2, 3. Despi ...