使用代码时Opera和IE中的语法错误:async()

时间:2017-10-25 05:42:29

标签: javascript jquery internet-explorer asynchronous async-await

我有一段代码,它适用于除Internet Explorer和Opera之外的所有浏览器。

以下是代码:JSFiddle

(async () => {

在IE中指向行 protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) { BindCS(); BindCC(); BindAG(); List<LUT_Assets_Masters> dt = this.GetData(); rptMarkers.DataSource = dt; rptMarkers.DataBind(); } } private List<LUT_Assets_Masters> GetData() { AssetTaggingEntities context = new AssetTaggingEntities(); List<LUT_Assets_Masters> am1 = null; if (DDSearch.SelectedValue == "1" && DDStatus.SelectedIndex >= 0 && DDCondition.SelectedIndex >= 0 && DDGroup.SelectedIndex >= 0) { am1 = (from am in context.LUT_Assets_Masters where am.CSID == DDStatus.SelectedIndex && am.CCID == DDCondition.SelectedIndex && am.AGrpID == DDGroup.SelectedIndex select am).ToList(); } else { am1 = (from am in context.LUT_Assets_Masters select am).ToList(); } return am1; } protected void DDS_SelectedIndexChanged(object sender, EventArgs e) { List<LUT_Assets_Masters> dt = this.GetData(); rptMarkers.DataSource = dt; rptMarkers.DataBind(); } protected void DDGroup_SelectedIndexChanged(object sender, EventArgs e) { List<LUT_Assets_Masters> dt = this.GetData(); rptMarkers.DataSource = dt; rptMarkers.DataBind(); } protected void DDCondition_SelectedIndexChanged(object sender, EventArgs e) { List<LUT_Assets_Masters> dt = this.GetData(); rptMarkers.DataSource = dt; rptMarkers.DataBind(); } protected void DDStatus_SelectedIndexChanged(object sender, EventArgs e) { List<LUT_Assets_Masters> dt = this.GetData(); rptMarkers.DataSource = dt; rptMarkers.DataBind(); } protected void DDSearch_SelectedIndexChanged(object sender, EventArgs e) { if (DDSearch.SelectedValue == "1") { Search.Visible = true; BArea.Visible = false; } if (DDSearch.SelectedValue == "2") { Search.Visible = false; BArea.Visible = true; } }

中的语法错误

知道为什么会这样,以及如何解决它?

正如我注意到它是一个ES6代码,无论如何转换一个与旧浏览器友好的不同代码仍然提供相同的输出?

1 个答案:

答案 0 :(得分:0)

IE不支持

asyncawait,自版本42以来仅支持Opera(请参阅bottom of MDN article)。不要在旧浏览器中使用ES6 - 使用Babel或其他转换器转换到ES5(尽管在IE的情况下可能是ES3?)。