【发布时间】:2021-02-25 21:08:04
【问题描述】:
大家好,我想知道如何从子组件调用 perent 函数 我尝试使用 $parent 来调用 perent 方法,但我有这个错误 typeError: _this.$parent.forceRender is not a function 这是我试图调用的父方法
methods: {
forceRender() {
this.componentKey += 1
}
},
这是子组件,你可以看到我正在尝试使用 $parent 调用父方法
this.$parent.forceRender()
【问题讨论】:
-
顺便说一句:
forceRerender听起来是个坏主意。你通常不应该做那样的事情。
标签: vue.js methods components parent-child parent