I have like this action in my app where I manupulate data inside created hook:
HTML template example:
<template>
<div>
<p v-for="item in items" :key="item.id">{{ item.title }}</p>
</div>
</template>
Note: As template in my app I use vue grid layout package really
Working code:
created () {
if(Array.isArray(this.predefinedItems)) {
for (let index = 0; index < this.predefinedItems.length; index++) {
this.items[index] = {...this.predefinedItems[index], ...{
i: index, x: 1, y: 1, w: 12, h: 8, accent: 'info'
}}
}
console.log(this.items)
}
}
Not working code:
created() {
this.emulateApiRequest()
}
methods: {
emulateApiRequest() {
setTimeout(() => {
if (Array.isArray(this.predefinedItems)) {
for (let index = 0; index < this.predefinedItems.length; index++) {
this.items[index] = {
...this.predefinedItems[index],
...{ i: index, x: 1, y: 1, w: 12, h: 8, accent: 'info'
}
}
}
console.log(this.items)
}
}, 500)
},
}
Why my template not updates when I emulate api request to set data?
$setmethod to update my array then?@NickM