-1
在這條線就顯示無法訪問的代碼編譯時錯誤:無法訪問的代碼
resolve(data)
是什麼原因造成的?
我的代碼:
zipCodeBlurEventCall(zipcode) {
if (!this.validationService.isValidZipCodeRequired(this.siteDetail.ZipCode)) {
this.clearInvalidFlags();
this.invalidZipCode = true;
this.siteDetail.WeatherLocation = "";
this.toastr.error("Please enter valid Zip Code");
}
else {
this.siteLoading = true;
this.queryString = "?zipcode=" + zipcode;
return new Promise((resolve, reject) => {
this.siteService.getStationByZipCode(this.queryString).then(data => {
this.element = data;
if (this.element == null) {
this.siteLoading = false;
this.invalidZipCode = true;
this.toastr.error("Invalid Zip Code");
return true;
} else {
this.siteDetail.StateName = this.states.find(item => item.StateId === this.siteDetail.StateId).StateName;
if (this.siteDetail.StateName.toLowerCase() == this.element.response.place.stateFull.toLowerCase()) {
this.siteDetail.WeatherLocation = this.element.response.place.name;
this.isWeatherFlag = true;
this.siteLoading = false;
this.invalidZipCode = false;
return false;
}
else {
this.siteLoading = false;
this.invalidZipCode = true;
this.toastr.error("Zip code does not match with the selected State");
return true;
}
}
resolve(data);
});
});
}
}
我剛醒來,但它看起來好像總是在可以達到「resolve」前返回,這意味着它永遠不會運行。儘管如此,你的大括號還是很不自在,所以很難通過查看它們的範圍來判斷它們。 – Carcigenicate