Extjs Ext.data.TreeStore在呈现树后是否修改了数据源?

Extjs Ext.data.TreeStore在呈现树后是否修改了数据源?,extjs,tree,sencha-touch,store,Extjs,Tree,Sencha Touch,Store,假设我有如下数据源: var data = [ { id: 1, name: 'name1', parentId: null, children: [ { id: 2, name: 'name2', parentId: 1 } ] }, {

假设我有如下数据源:

var data = [
    {
        id: 1,
        name: 'name1',
        parentId: null,
        children: [
            {
                id: 2,
                name: 'name2',
                parentId: 1
            }
        ]
    },
    {
        id: 3,
        name: 'name3',
        parentId: null,
        children: [
            {
                id: 4,
                name: 'name4',
                parentId: 3
            }
        ]
    }
]
var basic_grid_store = Ext.create('Ext.data.TreeStore', {
    storeId: 'basic_grid_store',
    model: 'TestModel',
    root: {
        children: []
    }
});

console.log(data);
// the data structure is correct at this time

basic_grid_store.setRootNode({children: data);

console.log(data);
// the data structure is incorrect at this time, in which the `children` attribute for each item was gone.
代码片段如下所示:

var data = [
    {
        id: 1,
        name: 'name1',
        parentId: null,
        children: [
            {
                id: 2,
                name: 'name2',
                parentId: 1
            }
        ]
    },
    {
        id: 3,
        name: 'name3',
        parentId: null,
        children: [
            {
                id: 4,
                name: 'name4',
                parentId: 3
            }
        ]
    }
]
var basic_grid_store = Ext.create('Ext.data.TreeStore', {
    storeId: 'basic_grid_store',
    model: 'TestModel',
    root: {
        children: []
    }
});

console.log(data);
// the data structure is correct at this time

basic_grid_store.setRootNode({children: data);

console.log(data);
// the data structure is incorrect at this time, in which the `children` attribute for each item was gone.
我找不到任何文档,有人能告诉我为什么
TreeStore
修改了我的数据源,因为它不应该发生吗?

是的,它确实改变了原始数组。我无法回答为什么会出现这种行为,您需要询问Ext架构师/开发人员,但您可以尝试的是:

basic_grid_store.setRootNode({children:Ext.clone(data)});

非常感谢你的解释