[英]using async-await to wait for an assignment inside a function in Vuejs
I have a function that does 2 things.我有一个功能可以做两件事。 I want to wait for the first line and then execute the second line.我想等待第一行,然后执行第二行。 The first line is a simple assignment.第一行是一个简单的赋值。 How can I do this using async-await without making the first assignment a function.我怎样才能使用 async-await 做到这一点而不使第一次分配成为一个函数。 The following code gives me an error in line 2.下面的代码在第 2 行给了我一个错误。
async eg(){
await a = b;
c.focus();
}
eg() {
this.a = this.b;
setTimeout(() => {
this.$refs["c"].focus();
}, 1);
}
As user Al-un mentioned using this.$nextTick();
正如用户 Al-un 提到的,使用this.$nextTick();
solved it beautifully.漂亮地解决了它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.