2
我有以下方法:更改方法使用Promise.all在打字稿
public static zoomInMap(times: number): void {
for (let i = 0; i < times; i++) {
let zoomInButton = element(by.css('#main > cc-map > div.google-map-base- container-inner > div > div.gmnoprint.gm-bundled-control.gm-bundled-control-on-bottom > div:nth-child(1) > div > div:nth-child(1)'));
zoomInButton.click();
browser.sleep(Config.ZOOM_ANIMATION_TIMEOUT).then(() => {
// console.log('Map Zoomed In');
});
}
}
我想讓它返回一個承諾。我想用Promise.all 像:
public static zoomInMap(times: number): Promise<any> {
return Promise.all(?) // ? I do not know how to do it
for (let i = 0; i < times; i++) {
let zoomInButton = element(by.css('#main > cc-map > div.google-map-base-container-inner > div > div.gmnoprint.gm-bundled-control.gm-bundled-control-on-bottom > div:nth-child(1) > div > div:nth-child(1)'));
zoomInButton.click();
browser.sleep(Config.ZOOM_ANIMATION_TIMEOUT).then(() => {
// console.log('Map Zoomed In');
});
}
}
我應該如何返工的代碼中使用Promise.all。對不起,跛腳的問題。