我有以下問題。我需要從REST服務器返回值。一切都很好,我得到了我想要的東西,但是有一個小問題。異步不起作用,我不知道爲什麼。我會通過圖像向您展示我的代碼和結果。承諾然後不工作異步?
代碼
並導致鉻
爲什麼不工作,我想工作?當然,結果應該已經 1/2 然後3.感謝所有幫助
js代碼
ngOnInit() {
this.error = this.getBlockedText();
}
private getBlockedText(): string {
let customTxt;
this.proxy.core.getUISettings({}).then(res => {
customTxt = res;
console.log('1');
}).catch(err => {
console.log('2');
})
console.log('3');
return customTxt;
}
請複製粘貼你的代碼,而不是...這將幫助我們幫助你 – Salketer
不要將代碼發佈爲圖像。 – hindmost
此外,你隱藏你的代碼中唯一有趣的部分... – Salketer