gpt4 book ai didi

javascript - 在没有 dojo/parse 的情况下使用 dijit

转载 作者:行者123 更新时间:2023-11-30 18:13:11 24 4
gpt4 key购买 nike

有没有办法使用 dijit 的 BorderContainerContentPane 使用现有的 HTML/标记创建布局并避免使用 dojo/parse 的 .parse() 方法?

我正在尝试将 RequireJS 与 dojo/dijit 的 svn 主干中的最新代码一起使用,但不能使用 .parse() 因为它依赖于 require.on RequireJS 中不存在的方法。

请注意,我有一个现有模板,无法以编程方式创建 BorderContainer,除非它需要一个参数来设置现有元素(该元素也具有无法更改/删除的现有内容)。

最佳答案

是的,所有小部件都可以通过编程方式创建。这就是 dojo/parser 在内部所做的事情。

举个例子:

require(["dojo/ready", "dijit/layout/BorderContainer", "dijit/layout/ContentPane", "dijit/layout/TabContainer"], function(ready, BorderContainer, ContentPane, TabContainer){
ready(function(){
// create a BorderContainer as the top widget in the hierarchy
var bc = new BorderContainer({style: "height: 500px; width: 800px;"});

// create a ContentPane as the left pane in the BorderContainer
var cp1 = new ContentPane({
region: "left",
style: "height: 100px",
content: "hello world"
});
bc.addChild(cp1);

// create a TabContainer as the center pane in the BorderContainer,
// which itself contains two children
var tc = new TabContainer({region: "center"});
var tab1 = new ContentPane({title: "tab 1"}),
tab2 = new ContentPane({title: "tab 2"});
tc.addChild( tab1 );
tc.addChild( tab2 );
bc.addChild(tc);

// put the top level widget into the document, and then call startup()
document.body.appendChild(bc.domNode);
bc.startup();
});
});

关于javascript - 在没有 dojo/parse 的情况下使用 dijit,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14074313/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com