I am looping though some data using a v-for and displaying it in a table. I want to conditionally display some text based on one of the values in the array
my html looks like
<div id="vue-wrapper"> <div class="table table-borderless" id="table"> <table class="table table-borderless" id="table"> <thead> <tr> <th>Name</th> <th>Status</th> <th>Actions</th> </tr> </thead> <tr :key=item v-for="item in items"> <td>@{{ item.module }}</td> <td>@{{ item.enabled }}</td> <div v-if="item.enabled == true"> <td>Disable Button </td> </div> <div v-else> <td>Enable Button </td> </div> </tr> </table> </div> </div> and my vue js looks like
const app = new Vue({ el: '#vue-wrapper', data: { items: [{"module":"Blog","enabled":false},{"module":"Booking","enabled":true},{"module":"Review","enabled":true}], hasError: true, hasDeleted: true, newItem: {'name': ''} }, created () { // this.getVueItems() }, methods: { getVueItems: function () { axios.get('/api/module/').then(response => { console.log(response.data) this.items = response.data; console.log(this.items); }); }, createItem: function () { }, deleteItem: function () { }, } }); But when I load the page, both the disabled button and enabled button text is displayed. and there is the following error
"TypeError: Cannot read property 'enabled' of undefined"
but i can read the enabled property in the for loop, so I am not sure what i need to change