No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

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

    Framework
    2
    3
    221
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • F
      felice last edited by

      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: ''
      ]
      SB 1 Reply Last reply Reply Quote 0
      • SB
        SB @felice last edited by

        @felice
        Just try this:

        this.tableData.forEach((item) => {
          console.log('name: ', item.name)
          console.log('frequency: ', item.frequency)
          console.log('prescription: ', item.prescription)
        }
        
        F 1 Reply Last reply Reply Quote 0
        • F
          felice @SB last edited by

          @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?

          1 Reply Last reply Reply Quote 0
          • First post
            Last post