How can I loop through an array variable in the data section under <script>?



  • I am trying to populate my data section under <script> with an array variable but can’t seem to do a for loop in it. Any advise?

    This is the array results:
    bb9f37ca-2c77-4d4a-8f4d-8a7d305a53e0-image.png

    Is there any way i can populate the above data into this section?

    tableData: [
      name: '',
      frequency: '',
      prescription: '',
      time: ''
    ]


  • @felice
    Just try this:

    this.tableData.forEach((item) => {
      console.log('name: ', item.name)
      console.log('frequency: ', item.frequency)
      console.log('prescription: ', item.prescription)
    }
    


  • @SB Thank you very much for you reply! The array results is stored in a variable called “results” and I am looking at using the results to create a quasar list <q-list>. Hence, I would like to use the array results and store them in tableData so that I will be able to create a q-list with :data=“tableData”. Perhaps I am able to iterate through the array results inside tableData?


Log in to reply