dijit.Tree 即使不存在 children,文件夹也会显示一个加号图标

dijit.Tree Folders appear with a icon PLUS even if no children are present

我正在使用以下代码渲染 dijit.Tree,正如您从图片中看到的那样,我遇到了这些问题:

你能告诉我我做错了什么吗?

   this._tree = new Tree({
        model: this._model,
        showRoot: false,
        autoExpand: false,
        persist: false,
        getLabel: function (item) {
            return item.name;
        }
    });
    this._tree.placeAt(this.node);
    this._tree.startup();

这是由于模型的方法mayHaveChildren
您必须覆盖此方法才能使其 "smarter"... 参见:https://dojotoolkit.org/documentation/tutorials/1.6/store_driven_tree/

mayHaveChildren(object) - Indicates whether or not an object may have children (prior to actually loading the children)

你可以参考这个例子: