Horman Lewis
Horman Lewis

Reputation: 366

How to fix 'Cannot read property '_wrapper' of undefined' error when using webpack with Vue?

I use axios to get information from DB. I get response from server in array:

response

My html tags: htmlTag

Js code looks like this:

    data() {
        return {
            departments: {
                id: 0,
                name: "name of company",
                nameZod: "name of company dif"
                },
            };
       },
    created() {
        axios
            .get('/SomeController/Departments')
            .then(response => {
                this.departments = response.data;
                console.log(this.departments);
            })
        }

I get an error: Cannot read property '_wrapper' of undefined. Its very strange cause I use similar code in other module and it works correctly.

Upvotes: 12

Views: 23757

Answers (6)

hrdom
hrdom

Reputation: 168

Check Pause on caught exceptions under Breakpoints in the sources panel. enter image description here

Then you can see the name variable that caused the problem (corresponding to @name=an undefined method) in Scope-Local. enter image description here

Upvotes: 0

Rajbir Sehrawat
Rajbir Sehrawat

Reputation: 51

You are calling some function in your component which is not defined in your component yet, Please check all of your functions in your component are defined.

For Example

You are using @click="something" but something() not defined in your component.

Upvotes: 2

Kamil Sobczyk
Kamil Sobczyk

Reputation: 387

It happened to me too, but with different reason (Vue + Vuetify. @click function must be attached to btn, not icon like below.

   <v-btn fab small>
       <v-icon @click="sendMessage">send</v-icon>
   </v-btn>

Upvotes: 0

Anurag Aron Tigga
Anurag Aron Tigga

Reputation: 339

This error occurs when a v-on:click OR @click directive in the template is missing the function it's pointing to, inside methods in your component.

Example:


//template
@click="callAgain"
...
methods : {
  //no function called callAgain
}

Upvotes: 11

alagaesia
alagaesia

Reputation: 1629

Maybe you have defined a function call somewhere (@click=something) and you haven't defined yet the function in methods. This happened to me, maybe it can be useful for someone

Upvotes: 63

Mehdi
Mehdi

Reputation: 756

you just need to initiate your departments as an array like this:

    data() {
        return {
            departments: [
                {
                    id: 0,
                    name: "name of company",
                    nameZod: "name of company dif"
                },
            ],
        };
    },

Upvotes: 0

Related Questions