javascript - 在 ES6 中,如何将额外的参数传递给 .then() 调用中的函数?

标签 javascript ecmascript-6 es6-promise

如果我有以下设置:

function entryPoint (someVariable) {

  getValue(arg)
    .then(anotherFunction)
}

function anotherFunction (arg1) {
}

我怎样才能制作someVariable可用于anotherFunction

最佳答案

你可以试试这个。

function entryPoint (someVariable) {
  getValue(arg)
    .then(anotherFunction(someVariable))
}

function anotherFunction(someVariable) {
  return function(arg1) {
  }
}

关于javascript - 在 ES6 中,如何将额外的参数传递给 .then() 调用中的函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34981293/

相关文章:

javascript - 在没有变量声明的情况下使用异步迭代

javascript - 将 keyDown 事件添加到 iframe 中的 Canvas

javascript - rails : Set multiple values for hidden_input_field using Javascript

javascript - 检查多个对象数组的项目

javascript - "let"与 "var"内的 "block"

javascript - 在异步操作完成之前解决 promise

javascript - Async Await 和 Promises - 如何改进语法

javascript - Chrome : Page action not working

javascript - 使用 Ajax 执行 php 文件

javascript - ES6 解构和模块导入