【发布时间】:2020-04-07 22:11:53
【问题描述】:
我似乎不知道如何在函数运行后调用函数。
Func1 位于componentA this.$refs.componentA.Func1()
Func2在本地方法this.Func2()中找到
函数完成后如何调用函数。
我已经尝试过这段代码的变体(承诺),但它有一个错误:
this.$refs.componentA
.Func1()
.then(response => {
this.Func2()
});
得到这些错误:
Error in v-on handler: "TypeError: Cannot read property 'then' of undefined
TypeError: Cannot read property 'then' of undefined
【问题讨论】:
-
如果
Func1不是异步的,就一个接一个地调用,即this.$refs.componentA.Func1(); this.Func2() -
Hey Phil - Func2() 在 Func1 之后立即运行,即使 Func1 尚未完成
-
那么
Func1中有什么内容?听起来这是一个糟糕的异步函数