首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Vows.js:访问从内部主题内部的外部主题返回的参数

Vows.js:访问从内部主题内部的外部主题返回的参数
EN

Stack Overflow用户
提问于 2011-09-01 15:02:02
回答 1查看 245关注 0票数 0

我想知道是否有任何方法可以从内部主题的测试中获得外部主题的返回值。如果这让人困惑,这里有一个例子:

代码语言:javascript
复制
"build.css" : {
  topic : function(file) {
    fs.readFile(fixtures + "/public/build.css", "utf8", this.callback);
  },
  'exists' : function(err, build) {
    assert.isNull(err); // This is fine..
  },
  {
    'should contain' : {
      topic : function() {
        return "wahoo";
      },
      'some cool css' : function(wahooString, err, build) {
        // Where did build go? Can I still access it from this scope?
      }
    ...
  }
  ...
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-09-01 21:32:02

伪码:

代码语言:javascript
复制
'should contain' : {
  topic : function(err, build) {
    this.callback(err, build, "wahoo");
    return undefined;
  },
  'some cool css' : function(err, build, wahooString) {
    // Where did build go? Can I still access it from this scope?
  }
...

基本上,您可以在任何子主题中获取以前的主题数据。然后,您需要手动将其传递给誓言。是的,这是一种痛苦。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/7266973

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档