【问题标题】:How to use classes defined with qxoo with nodejs?如何将 qxoo 定义的类与 nodejs 一起使用?
【发布时间】:2012-04-05 09:39:07
【问题描述】:
var qx = require('qooxdoo');
var t= new T(4080);
var t= new qx.T(4080);
// none of them are defined :s

我有我的主文件 run.js,然后是一个带有类的文件 T.js:

qx.Class.define("T", {
    extend : qx.core.Object,

    constructor: function(port){
        debugger;
        var self = this;
        this.port = port;
        this.server = http.createServer(function(req, res){
            self.onRequest.apply(self, arguments);
        });
        server.listen(port);
    },

    members : {
        onRequest: function(req, res){
            debugger;
            util.log('requested!');
        }
    }
 });

我错过了什么?

http://manual.qooxdoo.org/1.6/pages/server/overview.html 这里他们没有说如何使用其他文件,只在同一个文件中..所以我真的不知道该怎么做..

非常感谢任何帮助,谢谢(:

【问题讨论】:

    标签: node.js qooxdoo


    【解决方案1】:

    您缺少运行 T.js 文件的部分(通过要求它)。例如这样的工作:

    app.js:

    var qx = require('qooxdoo');
    require('./class-t'); // Run the file that creates the class.
    
    var t = new T();
    t.foo(); // logs "T#foo called"
    

    类-t.js:

    var qx = require('qooxdoo');
    
    qx.Class.define('T', {
      extend: qx.core.Object,
    
      members: {
        foo: function () {
          console.log('T#foo called');
        }
      }
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-04-01
      • 2018-08-22
      • 1970-01-01
      • 2018-06-02
      • 2010-11-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多