I'm new to vue, trying to display items inside array in the list
Vue component:
<template>
<div>
<ul id="array-rendering">
<li v-for="item in items" :key="item.message">
{{ item.message }}
</li>
</ul>
</div>
</template>
<script>
export default {
props: {
items: {
type: [],
default: [
{ message: 'Foo' },
{ message: 'Bar' }
]
},
},
}
</script>
<style scoped>
h4{
display: flex;
align-items: center;
justify-content: center;
}
</style>
Page:
<ErrorAlert v-bind:items="{result}"/>
Here,the result is
[
{ message: "Foo2" },
{ message: "Bar2" }
];
Instead of getting the values 'foo2' and 'bar2' i am getting the error:Expected array got object
Looked at similar post and tried to parse JSON but still not getting the expected result. Can anyone please help?