0

我有对象名称Roption,我想删除添加任务中的第三个元素。

这个=>"{ text: "Child", alias: "addsubbelowchild", action:menuAction}"

我正在使用Delete Roption.items[0].items[2]

它可以工作,但 Roption.items[0].items.length 即使在删除后也会返回相同的计数。

它是真的删除还是只是使其未定义?

 var Roption = { width: 150, items: [
                { text: "Add Task",  alias: "addtask", type: "group" , width : 130 , items : 
                    [   
                        { text: "Sibling",  alias: "addsiblingbelow", action : menuAction},
                        { text: "Child First", alias: "addsubaboveDirect", action: menuAction },
                        { text: "Child Last",  alias: "addsubbelowDirect", action: menuAction },
                        { text: "Child",  alias: "addsubbelowchild", action:menuAction},
                        { text: "Advanced Add",  alias: "advancedadd", type: "group" , width : 120 , items :
                            [
                                { text: "Sibling", alias: "addsibling", type: "group" , width : 120 ,items :
                                    [
                                        { text: "Below",  alias: "addsiblingbelow", action: menuAction },
                                        { text: "Above",  alias: "addsiblingabove", action: menuAction }
                                    ]
                                },
                                { text: "Child", alias: "addsubtask", type: "group" , width : 120 ,items :
                                    [
                                        { text: "First", alias: "addsubabove", action: menuAction },
                                        { text: "Last", alias: "addsubbelow", action: menuAction }
                                    ]
                                }
                            ]
                        }
                    ]
                }
            ]
                , onShow: applyrule
                , onContextMenu: BeforeContextMenu
                , onClose : AfterContextMenu
};
function menuAction(row) {}
function BeforeContextMenu(row) {}
function applyrule(row) {}
function AfterContextMenu(row) {}
4

1 回答 1

1

尝试使用.splice(index,howmany)

Roption.items[0].items.splice(2,1);
于 2013-10-18T08:11:37.610 回答