P粉1455438722023-08-31 00:57:07
The problem is with v-for, you can try to use: v-for="results in APIData.results"
, because "results" is not an accessor, but the value you give in the array Each value is assigned a name, and APIData is not an array.
P粉4818158972023-08-31 00:28:43
If you just want to loop through the results
in APIData
:
new Vue({ el: '#demo', data() { return { APIData: { "count": 1, "next": null, "previous": null, "results": [ { "url": "http://localhost:8000/v1/users/1/", "username": "admin", "email": "admin@example.com", "groups": [] }, { "url": "http://localhost:8000/v1/users/1/", "username": "user", "email": "user@example.com", "groups": [] } ] } } }, })
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script> <div id="demo"> <template> <div> <h1> Users </h1> <div v-for="result in APIData.results" :key="result.username"> <h5>{{ result.username }}</h5> <p>{{ result.email }}</p> </div> </div> </template> </div>