When trying to incorporate a prop into a computed value, I encounter the following error:
[Vue warn]: Error in render: "TypeError: Cannot read property 'length' of undefined" found in ---> at src/cmps/space-details/space-imgs.vue at src/pages/space-details.vue at src/App.vue
Could it be that I am using the prop incorrectly? Here is the component in question:
<template>
<div v-if="imgUrls.length" class="space-imgs" :class="pics">
<img :src="img" v-for="(img, idx) in imgUrls.slice(0, 5)" :key="idx" />
</div>
</template>
<script>
export default {
props: { imgUrls: Array },
computed: {
pics() {
return `pics-${this.imgUrls.length}`;
},
},
};
</script>
And here's how I'm passing the prop:
<space-imgs :imgUrls="space.imgUrls" />
Thank you!