Javascript 未加载Extjs树存储子节点

Javascript 未加载Extjs树存储子节点,javascript,extjs,Javascript,Extjs,我可以看到第一个节点加载了子节点,奇怪的是第二个节点没有加载子节点? 有什么想法吗 在这里拉小提琴 因为它们共享数据集(对象引用)。按如下方式修改您的商店: Ext.define('ComplexTree', { extend: 'Ext.data.TreeStore', alias: 'store.complextree', constructor: function (config) { config = config || {};

我可以看到第一个节点加载了子节点,奇怪的是第二个节点没有加载子节点? 有什么想法吗

在这里拉小提琴


因为它们共享数据集(对象引用)。按如下方式修改您的商店:

Ext.define('ComplexTree', {
    extend: 'Ext.data.TreeStore',
    alias: 'store.complextree',

    constructor: function (config) {
        config = config || {};
        config.root = {
            expanded: true,
            children: [{
                text: 'test',
                leaf: true
            }, {
                text: 'test2',
                expanded: true,
                children: [{
                    text: 'test21',
                    leaf: true
                }, {
                    text: 'test22',
                    leaf: true
                }]
            }, {
                text: 'test3',
                leaf: true
            }]
        };
        this.callParent([config]);
    }
});

有趣。你试着问了吗?是的,很有意思…不,我还没有工作,太棒了。你能告诉我这个config.root和call parent做什么吗?它在配置上设置root属性,然后调用父构造函数,传递配置。
Ext.define('ComplexTree', {
    extend: 'Ext.data.TreeStore',
    alias: 'store.complextree',

    constructor: function (config) {
        config = config || {};
        config.root = {
            expanded: true,
            children: [{
                text: 'test',
                leaf: true
            }, {
                text: 'test2',
                expanded: true,
                children: [{
                    text: 'test21',
                    leaf: true
                }, {
                    text: 'test22',
                    leaf: true
                }]
            }, {
                text: 'test3',
                leaf: true
            }]
        };
        this.callParent([config]);
    }
});