dojo 以编程方式在dijit布局中插入dijit内容窗格TitlePane

wswtfjt7  于 2022-12-16  发布在  Dojo
关注(0)|答案(1)|浏览(162)

x1c 0d1x我试图通过编程的方式将dijit/layout/ content窗格添加到dijit/title窗格中。我遇到的问题是我无法将content窗格放入title窗格中,它被放置在title窗格下面。我的代码如下:知道我哪里做错了吗
谢谢
皮特

[![require(\[
            "dijit/TitlePane",
            "dijit/layout/ContentPane",
            "dojo/dom",
            "dojo/domReady!"
        \], function (TitlePane, ContentPane, dom) {

            //create the title pane to hold the layer list
            var tp = new TitlePane({ title: "Layers", id: "tp" });
            dom.byId("viewDiv").appendChild(tp.domNode);
            tp.startup();

            var cp = new ContentPane({ id: "cp", content: "Test" });
            cp.placeAt("tp");
            cp.startup();
            dom.byId("tp").appendChild(cp.domNode);

        });][1]][1]
hec6srdp

hec6srdp1#

TitlePane作为属性内容,您需要使用它来设置contentpane
实施例1:

var titlePane = new dijit.TitlePane({
        title:"This",    
        open: false,
        content: new ContentPane({
            content:"Hello, I'm content pane inside a title pane",
            style:"background:red"
        })
    });

实施例2:

var cp = new ContentPnae({
           content:"Hello again, I'm CP within titlepane",
            style:"background:yellow"
});
    var titlePane = new dijit.TitlePane({
            title:"This too",    
            open: false           
        });
titlePane .set('content',cp.domNode);

相关问题