Question 11
Consider in this code Vue.js 2 CDN is used.
Index.html
<div id="app"> <ul> <li v-for="user in users">{{ user.name }}</li> </ul> <button @click="fetchUsers">Load Users</button></div>
<script>new Vue({ el: "#app", data: { users: [] }, methods: { fetchUsers() { fetch("https://jsonplaceholder.typicode.com/users") .then(res => res.json()) .then(data => { this.users = data; }); } }});</script>Which of the following statements is/are correct, assuming the given API is working?
Clicking the button fetches users and updates DOM.
Vue automatically re-renders the list when users changes.
v-for is used for conditional rendering.
The code demonstrates Vue’s reactivity system.