javascript - 箭头函数在大括号后用括号编译
问题描述
我有一个节点模块导入到我的 nuxtjs 应用程序中,其中包含这段代码:
shortcodes = await Promise.all(presets.map(preset => {
let promise;
if (preset.includes('/')) {
const [customLocale, customPreset] = preset.split('/');
promise = fetchShortcodes(customLocale, customPreset, opts);
} else {
promise = fetchShortcodes(locale, preset, opts);
} // Ignore as the primary dataset should still load
return promise.catch(() => ({}));
}));
但是,当我构建项目时,它会被编译成一种语法,该语法会引发有关意外令牌“{”的错误。原因是这段代码的构建代码如下所示:
f=await Promise.all(c.map((o=>{let n;if(o.includes("/")){const[e,t]=o.split("/");n=l(e,t,d)}else n=l(e,o,d);return n.catch((()=>({})))})))
您可以注意到o
( preset
) 前面有一个新括号。右括号几乎一直在最后。到目前为止,我不知道为什么会这样。我会很高兴我能得到任何关于如何移除一个支架或至少将它关闭在正确位置的指示。
解决方案
推荐阅读
- laravel - 我对 OpenTok 和 Nexmo API 有疑问
- google-places-api - Google Places 自动填充 API 限制
- c# - 当我抛出 ac# 异常时,IIS 日志中的 Http 500
- html - 以图像为中心的时间轴
- python - 我是否需要安装 Hadoop 才能使用 Pyspark 的各个方面?
- python - 如何仅对 30% 的数据使用 RandomizedSearchCV 或 GridSearchCV
- android - 编码时视频加密
- java - ByteArrayOutputStream 与 zipStream 到 InputStream
- python - 使用带有嵌入式 IMU 的 2D LiDar 进行 3D 映射
- sql - SQL SERVER 如何选择每组中的最新记录?