将Webpack与Vue结合使用时,如何解决“无法读取未定义的属性'_wrapper'”错误?

Hor*_*wis 0 webpack vue.js axios

我使用axios从数据库获取信息。我从阵列中的服务器得到响应:

响应

我的html标签: htmlTag

Js代码如下所示:

    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);
            })
        }
Run Code Online (Sandbox Code Playgroud)

我收到一个错误:无法读取未定义的属性'_wrapper'。这是非常奇怪的原因,因为我在其他模块中使用了类似的代码,并且可以正常工作。

小智 7

v-on:click OR @click模板中的指令在methods组件内部缺少它指向的函数时,会发生此错误。

例子:


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

Run Code Online (Sandbox Code Playgroud)


ala*_*sia 6

也许您已在某处(@ click = something)定义了一个函数调用,但尚未在方法中定义该函数。这件事发生在我身上,也许对某人有用

  • 正是如此。:) (2认同)