Javascript 如何在mxGraph中通过MouseeEvent使用对象(单元格)更改单元格样式?

Javascript 如何在mxGraph中通过MouseeEvent使用对象(单元格)更改单元格样式?,javascript,stylesheet,mxgraph,Javascript,Stylesheet,Mxgraph,我可以更改svg样式,但页面不工作,可能需要重新绘制()。如何操作 保存单元格节点的步骤 let svg = {} 点击功能 function clickFn(){ let keys = Object.keys(svg) keys.forEach((item,i)=>{ if(item.split('.')[0] === 'col' ){ svg[item].style = 'col' if(me.sourc

我可以更改svg样式,但页面不工作,可能需要重新绘制()。如何操作

保存单元格节点的步骤

let svg = {}
点击功能

function clickFn(){
    let keys = Object.keys(svg)
    keys.forEach((item,i)=>{
        if(item.split('.')[0] === 'col' ){
            svg[item].style = 'col'
            if(me.sourceState.cell.id === item){
                svg[item].style = 'active'
                //do not work!is need redraw()?
                //but svg[item] hasn't redraw()
            }else{
                svg[item].style = 'col'
            }
            // svg[item].shape.redraw();
        }
    })
}
事件侦听器

graph.addMouseListener({
    mouseDown: function(sender, me){
            if(me.sourceState && me.sourceState.cell && me.sourceState.cell.id.split('.')[0] === 'col'){
                clickFn()
            }
        },
    });
插入节点使用“列+列排序”保存

let WIDTH1 = 280,WIDTH2 = 250,WIDTH3 = 240,id = '';
this.dataBlood.forEach((fold,i)=>{
    svg['fold' + fold.sort] = graph.insertVertex(parent, null, '', 0, 0, WIDTH1, 0, 'column');
    fold.tables.forEach((table,index)=>{
        id = 'fold' + i + '.table' + index;
        svg[id] = graph.insertVertex(svg['fold' + fold.sort], id, table.name, 0, 0, WIDTH2, 30,'table');
        svg[id].collapsed = true;
        table.col.forEach((col)=>{
            svg['col.' + col.id] = graph.insertVertex(svg[id], 'col.' + col.id, col.name, 0, 0, WIDTH3, 20,'col');
        })
    })

})
插入链接

this.linkBlood.forEach((item=>{
    graph.insertEdge(parent, null,'' , svg['col.' + item.source], svg['col.' + item.target],'line');
}))

}

不知道您想做什么,但mxGraph中有大量“本机”功能,因此您不必手动触摸SVG。令人惊讶的是,您在示例中找不到帮助?我很想帮忙,但我真的不明白你想做什么。一点背景知识会有所帮助。