【发布时间】:2016-09-03 18:37:15
【问题描述】:
我正在尝试使用 jsplumb 来显示两个组件之间的连接。
我最终做的是使用 jQuery 来获取 UI 元素的句柄并使用它来呈现连接,以及 jsplumb 库。如下:
JsPlumb 配置
if( typeof jsPlumb !== 'undefined' && jsPlumb !== null ) {
jsPlumb.ready(function() {
jsPlumb.deleteEveryEndpoint();
jsPlumb.setContainer(this._container);
jsPlumb.Defaults.PaintStyle = { strokeStyle:'#339900', lineWidth:2, dashstyle: '3 3'};
jsPlumb.Defaults.EndpointStyle = { radius:7, fillStyle:'#339900' };
jsPlumb.importDefaults({
Connector : [ 'Flowchart', { curviness:0 } ],
ConnectionsDetachable:true,
ReattachConnections:true
});
jsPlumb.endpointClass = 'endpointClass';
jsPlumb.connectorClass = 'connectorClass';
});
}
Js-Plumb 用法
jsPlumb.connect({
source: $('#'+entityFrom+'Panel'),
target: $('#'+entityTo+'Panel'),
anchors: ['RightMiddle', 'LeftMiddle']
});
从有关 angular2 的各种博客中,我了解到将 jQuery 与 ng2 一起使用是一种反模式。
谁能提供一种替代或更好的设计方法来将 jsPlumb 与 angular2 或任何其他类似库一起使用。
【问题讨论】:
标签: jquery html angular jsplumb angular2-template