且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

通过babel使用async/await-require("babel-polyfill")行不在构建文件的顶部

更新时间:2023-09-28 08:23:52

自定义函数以来,例如

async function foo() {
    return 10;
}

可以在使用之前使用在javascript中定义,Babel会在编译过程中将其移至文件顶部.

can be used before they're defined in javascript, Babel is moving it to the top of the file during transpilation.

要解决此问题,请尝试尝试调整语法:

To work around this, this try adjusting your syntax if possible:

const foo = async function() {
    return 10;
}