qooxdoo qooxdoo-compiler如何使用部件

时间:2018-01-26 18:55:21

标签: javascript qooxdoo

我正在玩和测试qooxdo-compiler,如何用part编译?

我有这个脚本,但它在Window或Linux中不起作用。

的application.js

/*
*
* @use(webApp.EmptyWindow)
*/
qx.Class.define("webApp.Application", {
    extend : qx.application.Standalone,
    members : {
        main : function() {
            this.base(arguments);
            if (qx.core.Environment.get("qx.debug")) {
                qx.log.appender.Native;
                qx.log.appender.Console;
            }
            var button1 = new qx.ui.form.Button("Click me");
            var doc = this.getRoot();
            doc.add(button1);
            button1.addListener("execute", function() {

                // this work.!!!
                //var emptyWindow = webApp.EmptyWindow.getInstance();
                //emptyWindow.open();

               // NO WORK.!
                var sfile = "webApp.EmptyWindow";
                qx.io.PartLoader.require(sfile, function () {
                    var miWin = qx.Class.getByName(sfile).getInstance();
                    miWin.open();
                });
            });
        }
    }
});

EmptyWindow.js

qx.Class.define("webApp.EmptyWindow", {
    extend: qx.ui.window.Window,
    type: 'singleton',
    construct: function () {
        this.base(arguments, 'TestOne');

        this.set({modal: true});
    }
});

compile.js

{
  "targets": [
    {
      "type": "source",
      "outputPath": "source-output"
    },
    {
      "type": "hybrid",
      "outputPath": "hybrid-output"
    },
    {
      "type": "build",
      "outputPath": "build-output"
    }
  ],

  "defaultTarget": "source",
  "locales": ["en"],

  "applications": [
    {
      "class": "webApp.Application",
      "theme": "webApp.theme.Theme",
      "name": "webApp",
      "boot": "source/boot",
        "parts": {
            "boot": {
                "include": [ "webApp.Application", "webApp.theme.Theme" ],
                "exclude": []
            },
            "addClazz": {
                "include": [ "webApp.EmptyWindow" ]
            }
        }
    }
  ],

  "libraries": [
    "../qooxdoo-master/framework",
    "."
  ]
}

错误是:

  

未捕获错误:部件中未找到“webApp.EmptyWindow”部分(boot,addClazz)

有什么问题?

1 个答案:

答案 0 :(得分:1)

您的部分称为addClazz,而不是webApp.EmptyWindow。换句话说,qx.Part.require需要部件的名称,而不是相关部件中的类名。