小编Wei*_*ang的帖子

coffeescript承诺链接功能定义

当承诺在coffeescript中进行链接时,为此定义的函数需要绑定到'this'.

  $q.fcall somecall
  .then ((url)->
    dosomething()
    ).bind(this)
  .catch (err)->
    console.log 'error occured', err
Run Code Online (Sandbox Code Playgroud)

但是,以上编译成以下内容,这是错误的.那怎么写呢?或者有没有办法让coffeescript代表这个?

  $q.fcall(somecall).then(((function(url) {
    dosomething()
  }).bind(this))["catch"](function(err) {
    return console.log('error occured', err);
  })));
Run Code Online (Sandbox Code Playgroud)

javascript coffeescript q

5
推荐指数
1
解决办法
2109
查看次数

标签 统计

coffeescript ×1

javascript ×1

q ×1