单行到多行ES6粗箭头功能?

VikR:

我正在学习ES6粗箭头功能。更改此代码的正确方法是什么,以便即使const a = 100;在指示的位置也可以放置另一行,以便我可以在此函数中添加更多行?

IMAdded: (options, args) => ({
    IMAdded: {
        filter: newIM => true, *need to add another line here*
    },
}),

更新:

这是运行的ES6代码:

const subscriptionManager = new SubscriptionManager({
    schema,
    pubsub,
    setupFunctions: {
        APPTAdded: (options, args) => ({
            APPTAdded: {
                filter: appointment => (true),
            },
        }),
});

我想在返回的代码中添加更多行true

nem035:

如果要将以下方法转换为更多行:

{
  filter: appointment => true
}

您必须添加花括号和一条return语句:

{
  filter: appointment => {
    // ... add your other lines here
    return true;
  }
}

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章