Skip to content

TypeError: Cannot read property 'length' of undefined #6018

@ahmedkhan847

Description

@ahmedkhan847

Version

2.3.4

Reproduction link

https://github.com/ahmedkhan847/commentwithlaravelandvue/blob/master/resources/assets/js/components/Comments.vue

Steps to reproduce

Working with vuejs as I upgraded to vuejs2 I am unable to get the length of an array exist within an array. I am unable to get its length inside a vuejs function but not in template.

<div class="form-row reply" v-if="comment.replies.length > 1">
                    <a v-if="viewcomment[index]" @click="showComments(index)">Hide comments {{comment.replies.length - 1}}</a>
                    <a v-else @click="showComments(index)">View more {{comment.replies.length - 1}} comments </a>
                </div>

What is expected?

I was expecting to get the length of array.

What is actually happening?

I am getting error "TypeError: Cannot read property 'length' of undefined"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions