this.uploadFileMixin(this.file, "/releaseReplyTaskFile").then((res) => { let fileUrl = res; console.log("imageUrl is ", fileUrl); this.fileUrl = fileUrl; this.getSgfInfo(fileUrl); }); var replyPlayer = 1; if (this.replyPlayer == "复盘白方" || this.replyPlayer == 2) { replyPlayer = 2; } var data = { replyPlayer: replyPlayer, sgfUrl: this.fileUrl, totalHead: this.totalHead, };这段代码,想先执行完this.getSgfInfo(fileUrl)再给totalHead赋值
时间: 2024-01-11 07:05:52 浏览: 67
pdf.js前端插件,用于在线预览pdf文件
可以将赋值操作放在this.getSgfInfo(fileUrl)的回调函数中,即在获取到sgf信息后再进行赋值操作。可以按照以下方式修改代码:
```
this.uploadFileMixin(this.file, "/releaseReplyTaskFile").then((res) => {
let fileUrl = res;
console.log("imageUrl is ", fileUrl);
this.fileUrl = fileUrl;
this.getSgfInfo(fileUrl, () => {
var replyPlayer = 1;
if (this.replyPlayer == "复盘白方" || this.replyPlayer == 2) {
replyPlayer = 2;
}
this.totalHead = data.totalHead; // 在回调函数中进行赋值操作
});
});
getSgfInfo(fileUrl, callback) {
// 获取sgf信息的代码
// 获取完成后执行回调函数
callback();
}
```
这样就可以保证在获取到sgf信息后再进行赋值操作。
阅读全文