zoukankan      html  css  js  c++  java
  • React与jsplumb

    1.安装

    npm install jsplumb

    2.react中引用

    import jsplumb from 'jsplumb';
    const jsPlumbIn = jsplumb.jsPlumb;

    3.实例

    import React, { Component } from 'react';
    import jsplumb from 'jsplumb';
    import $ from 'jquery';
    const jsPlumbIn = jsplumb.jsPlumb;
    
    class Dotcon extends Component {
        componentDidMount(){
            var common = {
                isSource: true,
                isTarget: true,
                connector: ['Straight']
              }
            jsPlumbIn.ready(function () {
                jsPlumbIn.connect({
                    connector:'Flowchart',
                    source: 'item_left',
                    target: 'item_right',
                    endpoint: 'Rectangle',
                    paintStyle: { stroke: 'red', strokeWidth: 3 },
                    endpointStyle: { fill: 'red', outlineStroke: 'darkgray', outlineWidth: 2 },
                    overlays: [ ['Arrow', {  12, length: 12, location: 0.5 }] ]
                })
                jsPlumbIn.addEndpoint('item_left', {
                    anchors: ['Right']
                  }, common)
            
                  jsPlumbIn.addEndpoint('item_right', {
                    anchor: 'Left'
                  }, common)
            
                  jsPlumbIn.addEndpoint('item_right', {
                    anchor: 'Right'
                  }, common)
            })
            jsPlumbIn.draggable('item_left')
            jsPlumbIn.draggable('item_right')
        }
        render() {
            let diagramContainer={
                padding: '20px',
                 '80%',
                height: '200px',
                border: '1px solid gray'
            };
            let item={
                position: 'absolute',
                height: '80px',
                 '80px',
                border: '1px solid blue',
                color: 'blue',
                float: 'left'
            };
            let leftPo={
                position: 'absolute',
                height: '80px',
                 '80px',
                border: '1px solid blue',
                color: 'blue',
                float: 'left',
                left:'150px'
            };
            return (
                <div className="Dotcon" style={diagramContainer}>
                    <div id="item_left" style={item}></div>
                    <div id="item_right" style={leftPo}></div>
                </div>
            );
        }
      }
      
      export default Dotcon;
  • 相关阅读:
    ES6 数值
    ES6 字符串
    ES6 Reflect 与 Proxy
    ES6 Map 与 Set
    es6 Symbol
    新兴的API(fileReader、geolocation、web计时、web worker)
    浏览器数据库 IndexedDB 入门教程
    离线应用与客户端存储(cookie storage indexedDB)
    javascript高级技巧篇(作用域安全、防篡改、惰性载入、节流、自定义事件,拖放)
    ajax与comet
  • 原文地址:https://www.cnblogs.com/chrisweiii/p/10518421.html
Copyright © 2011-2022 走看看