Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
dojo 1.7,在子类'中设置ContentPane的内容;建造师_Dojo_Dijit.layout - Fatal编程技术网

dojo 1.7,在子类'中设置ContentPane的内容;建造师

dojo 1.7,在子类'中设置ContentPane的内容;建造师,dojo,dijit.layout,Dojo,Dijit.layout,我有以下派生自ContentPane的子类: define([ "dijit/layout/ContentPane", "dojo/_base/declare" ], function (ContentPane, declare) { var view = declare("client.View", ContentPane, { html: null, constructor: f

我有以下派生自ContentPane的子类:

define([
        "dijit/layout/ContentPane",
        "dojo/_base/declare"
    ],

    function (ContentPane, declare) {
        var view = declare("client.View", ContentPane, {
            html: null,
            constructor: function (args) {
                declare.safeMixin(this, args);
                if (this.html !== null) {
                    this.set("content", this.html);
                }
            }
        });
        return view;
    }
);
现在,以下代码在“this.set(“content”,this.html);”行上抛出TypeError:

var html=“你好”;
var view=view(html);

如何正确设置ContentPane的内容?

Ken Benjamin回答了我关于Dojo社区的问题(http://dojotoolkit.org/community/):

您试图在小部件生命周期中过早设置内容。尝试在postCreate而不是构造函数中执行此操作

在此处阅读有关小部件生命周期的更多信息:

var html = "<div>Hello</div>";
var view = View(html);