2016-06-10 17 views
0

當克隆對象我知道如何改變,例如>新聯合JS

Clone Object 1 2 times var m5 = m1.clone().translate(300, 0).attr('rect/fill', '#F69F43').attr('.label/text', 'Model 2').addTo(graph); 

這裏改變名稱ATTR標籤/文本

屬性,但是有這個元素:

var m1 = new joint.shapes.devs.Model({ 
position: { x: 300, y: 50 }, 
size: { width: 120, height: 150 }, 
inPorts: ['in1','in2','in3','in4'], 
outPorts: ['out'], 
attrs: { '.label': { text: 'Model1', 'ref-x': .4, 'ref-y': .2 }, rect: { fill: '#2ECC71' }, 
'.inPorts circle': { fill: '#16A085', magnet: 'passive', type: 'input' }, 
'.outPorts circle': { fill: '#E74C3C', type: 'output' }, 
'.name': { name: 'Bloque1' } } }).addTo(graph); 

如何克隆更改.inPorts圈填充???

由於

回答

0

var m5 = m1.clone().attr('.inPorts circle/fill', 'red').addTo(graph);改變每個輸入端口的顏色爲紅色。你可以用m5.attr('.inPorts>.port3>circle/fill' ,'green')

+0

改變特定端口的顏色。很酷..感謝隊友它的作品licke魅力 –