异步函数声明期望';'在Internet Explorer中 [英] async function declaration expects ';' in Internet Explorer

查看:58
本文介绍了异步函数声明期望';'在Internet Explorer中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个异步功能声明,该声明可在Chrome和Firefox上运行,但在Internet Explorer中出现以下错误.

I have an async function declaration that works on Chrome and Firefox, but gives the following error in internet explorer.

SCRIPT1004:应为';'

SCRIPT1004: Expected ';'

文件:javascriptFile.js,第5行,第7列

File: javascriptFile.js, Line: 5, Column 7

这是文件顶部具有这两个功能的简化版本,但在Internet Explorer上仍然失败.

This is the simplified version with these two function at the top of the file, and it still fails on internet explorer.

function sleep (ms) {
  return new Promise(function (resolve) { setTimeout(resolve, ms) })
}

async function begging (help) {
  await sleep(1000)
  console.log('please')
}

我似乎找不到关于无法在Internet Explorer中声明异步功能的任何信息.我真的很感谢您的帮助,不知道下一步该怎么解决.

I can not seem to find anything about not being able to declare async functions in internet explorer. I would really appreciate any help at all, I'm not sure where to look next in order to figure this out.

推荐答案

Internet Explorer不支持 async 函数,并且永远不会本机地运行.使用新的JavaScript功能的主要缺点是缺乏支持.

Internet Explorer does not support async functions, and never natively will. The main drawback of using new JavaScript features is lack of support.

这篇关于异步函数声明期望';'在Internet Explorer中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆