Search code examples
vue.jsnuxt.js

how to get value name in object user with v-for in nuxt js?


this my array

 [
  {
    created_at: "2020-09-24T19:30:14.000Z",
    user: {
         id: "xxx-xxx-xxx",
         name: "John Doe",
    },
  }
]
      

I want to retrieve the data name in the user object, can anyone give me an example of how to retrieve the data?


Solution

  •     <p v-for=" (user ,i) in users" :key="i"> {{user.user.name}}</p>
    

    <script>
    export default {
        data() {
            return {
                users: [{
                    created_at: "2020-09-24T19:30:14.000Z",
                    user: {
                        id: "xxx-xxx-xxx",
                        name: "John Doe",
                    },
                }]
            }
        }
    }
    </script>