我尝试使用qooxdoo 3.5构建应用程序,并遇到问题,而不是添加树,我收到错误:
未捕获的TypeError:无法读取属性' Tree'未定义的
该应用程序使用演示中的两个代码部分:widget-tree和layout-hsplit。 我尝试重建应用程序,并修改config.json文件(没有帮助,也许我做错了)。 代码在这里:
/**
* This is the main application class of your custom application "sphinx2"
*
* @asset(sphinx2/*)
*/
qx.Class.define("sphinx2.Application",
{
extend : qx.application.Standalone,
members :
{
/**
* This method contains the initial application code and gets called
* during startup of the application
*
* @lint ignoreDeprecated(alert)
*/
main : function()
{
// Call super class
this.base(arguments);
this.addSplitPaneTwoFlexSimple();
var hBox = new qx.ui.layout.HBox();
hBox.set(
{
spacing: 20
});
var container = new qx.ui.container.Composite(hBox);
this.getRoot().add(container);
var tree = this.getTree();
container.add(tree);
var commandFrame = this.getCommandFrame(tree);
container.add(commandFrame);
// Enable logging in debug variant
if (qx.core.Environment.get("qx.debug"))
{
// support native logging capabilities, e.g. Firebug for Firefox
qx.log.appender.Native;
// support additional cross-browser console. Press F7 to toggle visibility
qx.log.appender.Console;
}
},
addSplitPaneTwoFlexSimple : function()
{
var splitpane = new qx.ui.splitpane.Pane("horizontal");
splitpane.setWidth(400);
splitpane.setHeight(60);
splitpane.setDecorator("main");
this.getRoot().add(splitpane, {left:20, top:20});
// Left
var leftWidget = new qx.ui.form.TextArea("Flex:1");
leftWidget.setDecorator(null);
leftWidget.setWrap(true);
splitpane.add(leftWidget, 1);
// Right
var rightWidget = new qx.ui.form.TextArea("Flex:2");
rightWidget.setDecorator(null);
rightWidget.setWrap(true);
splitpane.add(rightWidget, 2);
},
getTree : function()
{
var tree = new qx.ui.tree.Tree().set({
width : 200,
height : 400,
draggable: true
});
var root = new qx.ui.tree.TreeFolder("root");
root.setOpen(true);
tree.setRoot(root);
var te1 = new qx.ui.tree.TreeFolder("Desktop");
te1.setOpen(true);
te1.setIcon("icon/22/places/user-desktop.png");
root.add(te1);
var te1_1 = new qx.ui.tree.TreeFolder("Files");
var te1_2 = new qx.ui.tree.TreeFolder("Workspace");
var te1_3 = new qx.ui.tree.TreeFolder("Network");
var te1_4 = new qx.ui.tree.TreeFolder("Trash");
te1.add(te1_1, te1_2, te1_3, te1_4);
var te1_2_1 = new qx.ui.tree.TreeFile("Windows (C:)");
var te1_2_2 = new qx.ui.tree.TreeFile("Documents (D:)");
te1_2.add(te1_2_1, te1_2_2);
var te2 = new qx.ui.tree.TreeFolder("Inbox");
var te2_1 = new qx.ui.tree.TreeFolder("Presets");
var te2_2 = new qx.ui.tree.TreeFolder("Sent");
var te2_3 = new qx.ui.tree.TreeFolder("Trash");
for (var i=0; i<30; i++) {
te2_3.add(new qx.ui.tree.TreeFile("Junk #" + i));
}
var te2_4 = new qx.ui.tree.TreeFolder("Data");
var te2_5 = new qx.ui.tree.TreeFolder("Edit");
te2.add(te2_1, te2_2, te2_3, te2_4, te2_5);
root.add(te2);
return tree;
},
}
});
请告诉我,我做错了什么?
答案 0 :(得分:0)
听起来像生成的应用程序中不包含qx.ui.tree.Tree依赖项。您确定使用了适当的生成器作业,即generate.py source
用于开发版本(sphinx2/source/index.html
)吗?
答案 1 :(得分:0)
做一个./generate distclean,然后一个./generate source-all,看看错误是否仍然发生 - 没有发生在我身上,而且由于过去的缓存损坏我确实遇到了错误的构建。
在构建和运行上面的代码时,我得到的是一个错误,说getCommandFrame()不是一个函数 - 很可能是因为你忘了包含它。
答案 2 :(得分:0)
所以,我玩了代码,并发现第二个函数之后的逗号应该被删除,并且可以在函数中完成树声明,而不是在函数之外。谢谢你的时间。产生的工作代码:
/**
* This is the main application class of your custom application "sphinx2"
*
* @asset(sphinx2/*)
*/
qx.Class.define("sphinx2.Application",
{
extend : qx.application.Standalone,
/*
*****************************************************************************
MEMBERS
*****************************************************************************
*/
members :
{
/**
* This method contains the initial application code and gets called
* during startup of the application
*
* @lint ignoreDeprecated(alert)
*/
main : function()
{
// Call super class
this.base(arguments);
this.addSplitPaneTwoFlexSimple();
// Enable logging in debug variant
if (qx.core.Environment.get("qx.debug"))
{
// support native logging capabilities, e.g. Firebug for Firefox
qx.log.appender.Native;
// support additional cross-browser console. Press F7 to toggle visibility
qx.log.appender.Console;
}
},
/*
-------------------------------------------------------------------------
Below is your actual application code...
-------------------------------------------------------------------------
*/
addSplitPaneTwoFlexSimple : function()
{
var splitpane = new qx.ui.splitpane.Pane("horizontal");
splitpane.setWidth(400);
splitpane.setHeight(60);
splitpane.setDecorator("main");
this.getRoot().add(splitpane, {left:20, top:20});
// Left
var tree = this.getTree();
splitpane.add(tree, 1);
// Right
var rightWidget = new qx.ui.form.TextArea("Flex:2");
rightWidget.setDecorator(null);
rightWidget.setWrap(true);
splitpane.add(rightWidget, 2);
},
getTree : function()
{
var tree = new qx.ui.tree.Tree().set({
draggable: true
});
var root = new qx.ui.tree.TreeFolder("root");
root.setOpen(true);
tree.setRoot(root);
var te1 = new qx.ui.tree.TreeFolder("Desktop");
te1.setOpen(true);
te1.setIcon("icon/22/places/user-desktop.png");
root.add(te1);
var te1_1 = new qx.ui.tree.TreeFolder("Files");
var te1_2 = new qx.ui.tree.TreeFolder("Workspace");
var te1_3 = new qx.ui.tree.TreeFolder("Network");
var te1_4 = new qx.ui.tree.TreeFolder("Trash");
te1.add(te1_1, te1_2, te1_3, te1_4);
var te1_2_1 = new qx.ui.tree.TreeFile("Windows (C:)");
var te1_2_2 = new qx.ui.tree.TreeFile("Documents (D:)");
te1_2.add(te1_2_1, te1_2_2);
var te2 = new qx.ui.tree.TreeFolder("Inbox");
var te2_1 = new qx.ui.tree.TreeFolder("Presets");
var te2_2 = new qx.ui.tree.TreeFolder("Sent");
var te2_3 = new qx.ui.tree.TreeFolder("Trash");
for (var i=0; i<30; i++) {
te2_3.add(new qx.ui.tree.TreeFile("Junk #" + i));
}
var te2_4 = new qx.ui.tree.TreeFolder("Data");
var te2_5 = new qx.ui.tree.TreeFolder("Edit");
te2.add(te2_1, te2_2, te2_3, te2_4, te2_5);
root.add(te2);
return tree;
}
}
});