joekenpat
joekenpat

Reputation: 387

how to fix 'property or method is not defined' error in VueJS

Am passing an array props from a parent component to a child component i can see the props array using vue-devtools passed successfully, but when i try to render with:

<template :v-for="(item, index) in messages_array">

i get:

vue.runtime.esm.js?2b0e:619 [Vue warn]: Property or method "item" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property.

I want the v-for to iterate over the prop supplied.

Below are links to image of code... tried pasting them here but couldnt format them properly.

Single File component Recieving the prop

component Recieving the prop Script

The Parent Component

The Parent Component Script

Upvotes: 1

Views: 1136

Answers (1)

Simon Thiel
Simon Thiel

Reputation: 3285

Using v-for instead of :v-for should resolve your issue:

<template v-for="(item, index) in messages_array">

Full documentation can be found here: https://v2.vuejs.org/v2/guide/list.html#Mapping-an-Array-to-Elements-with-v-for

Upvotes: 0

Related Questions