最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

vue+jsplumb實現(xiàn)連線繪圖

 更新時間:2022年03月29日 16:43:30   作者:qq_37656005  
這篇文章主要為大家詳細(xì)介紹了vue+jsplumb實現(xiàn)連線繪圖,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下

vue+jsplumb實現(xiàn)連線繪圖,供大家參考,具體內(nèi)容如下

jsPlumb是一個比較強大的繪圖組件,它提供了一種方法,主要用于連接網(wǎng)頁上的元素。在現(xiàn)代瀏覽器中,它使用SVG或者Canvas技術(shù),而對于IE8以下(含IE8)的瀏覽器,則使用VML技術(shù)。

效果圖

1.安裝

npm install jsplumb --save

2.main.js 引入

import jsPlumb from 'jsplumb'
Vue.prototype.$jsPlumb = jsPlumb.jsPlumb

3.示例代碼

<template>
? <div>
? ? <div id="container">
? ? ? <div class="left">
? ? ? ? <ul>
? ? ? ? ? <li v-for="(item,index) in leftList" :key="'left' + index" :id="item.nodeId" name="source">
? ? ? ? ? ? {{item.name}}
? ? ? ? ? </li>
? ? ? ? </ul>
? ? ? </div>

? ? ? <div class="right">
? ? ? ? <ul>
? ? ? ? ? <li v-for="(item,index) in rightList" :key="'right' + index" :id="item.nodeId" name="target">
? ? ? ? ? ? {{item.name}}
? ? ? ? ? </li>
? ? ? ? </ul>
? ? ? </div>
? ? </div>
? </div>
</template>

<script>
? export default {
? ? name: "linkElementModal",
? ? data() {
? ? ? return {
? ? ? ? jsPlumb: null, // 緩存實例化的jsplumb對象
? ? ? ? leftList:[
? ? ? ? ? {name: 'xxx_left_1', nodeId: 'left_1'},
? ? ? ? ? {name: 'xxx_left_2', nodeId: 'left_2'},
? ? ? ? ? {name: 'xxx_left_3', nodeId: 'left_3'},
? ? ? ? ? {name: 'xxx_left_4', nodeId: 'left_4'}
? ? ? ? ],
? ? ? ? rightList:[
? ? ? ? ? {name: 'xxx_right_1', nodeId: 'right_1'},
? ? ? ? ? {name: 'xxx_right_2', nodeId: 'right_2'},
? ? ? ? ? {name: 'xxx_right_3', nodeId: 'right_3'},
? ? ? ? ? {name: 'xxx_right_4', nodeId: 'right_4'}
? ? ? ? ]
? ? ? }
? ? },
? ? mounted(){
? ? ? this.showPlumb();
? ? },
? ? methods:{
? ? ? showPlumb() {
? ? ? ? this.jsPlumb = this.$jsPlumb.getInstance({
? ? ? ? ? Container: 'container', // 選擇器id
? ? ? ? ? EndpointStyle: {radius: 0.11, fill: '#999'}, // 端點樣式
? ? ? ? ? PaintStyle: {stroke: '#999', strokeWidth: 2}, // 繪畫樣式,默認(rèn)8px線寬 ?#456
? ? ? ? ? HoverPaintStyle: {stroke: '#994B0A', strokeWidth: 3 }, // 默認(rèn)懸停樣式 ?默認(rèn)為null
? ? ? ? ? ConnectionOverlays: [ // 此處可以設(shè)置所有箭頭的樣式
? ? ? ? ? ? ['Arrow', { // 設(shè)置參數(shù)可以參考中文文檔
? ? ? ? ? ? ? location: 1,
? ? ? ? ? ? ? length: 12,
? ? ? ? ? ? ? paintStyle: {
? ? ? ? ? ? ? ? stroke: '#999',
? ? ? ? ? ? ? ? fill: '#999'
? ? ? ? ? ? ? }
? ? ? ? ? ? }]
? ? ? ? ? ],
? ? ? ? ? Connector: ['Straight'], // 要使用的默認(rèn)連接器的類型:直線,折線,曲線等
? ? ? ? ? DrapOptions: {cursor: 'crosshair', zIndex: 2000}
? ? ? ? });

? ? ? ? this.jsPlumb.batch(() => {
? ? ? ? ? for(let i = 0; i < this.leftList.length; i++){
? ? ? ? ? ? this.initLeaf(this.leftList[i].nodeId, 'source');
? ? ? ? ? }
? ? ? ? ? for(let j = 0; j < this.rightList.length; j++){
? ? ? ? ? ? this.initLeaf(this.rightList[j].nodeId , 'target')
? ? ? ? ? }
? ? ? ? })

? ? ? ? this.setjsPlumb(true,true);

? ? ? ? //點擊連線
? ? ? ? this.jsPlumb.bind('click', ?(conn, originalEvent) => {
? ? ? ? ?console.log(conn, originalEvent)
? ? ? ? })

? ? ? ? //連線時觸發(fā)
? ? ? ? this.jsPlumb.bind('connection', ?(conn, originalEvent) => {
? ? ? ? ? console.log(conn.sourceId)
? ? ? ? ? console.log(conn.targetId)
? ? ? ? })

? ? ? ? //右鍵觸發(fā)
? ? ? ? this.jsPlumb.bind('contextmenu', ?(conn, originalEvent) => {
? ? ? ? ? console.log(conn, originalEvent)
? ? ? ? })
? ? ? },
? ? ? // ?初始化規(guī)則使其可以連線、拖拽
? ? ? initLeaf(id, type) {
? ? ? ? const ins = this.jsPlumb;
? ? ? ? const elem = document.getElementById(id);
? ? ? ? if (type === 'source') {
? ? ? ? ? ins.makeSource(elem, {
? ? ? ? ? ? anchor: [1, 0.5, 0, 0], // 左 上 右 下
? ? ? ? ? ? allowLoopback: false, //允許回連
? ? ? ? ? ? maxConnections: -1 //最大連接數(shù)(-1表示不限制)
? ? ? ? ? })
? ? ? ? } else {
? ? ? ? ? ins.makeTarget(elem, {
? ? ? ? ? ? anchor: [0, 0.5, 0, 0],
? ? ? ? ? ? allowLoopback: false,
? ? ? ? ? ? maxConnections: -1
? ? ? ? ? })
? ? ? ? }
? ? ? },
? ? ? setjsPlumb(sourceFlag, targetFlag){
? ? ? ? const source = document.getElementsByName('source')
? ? ? ? const target = document.getElementsByName('target')

? ? ? ? this.jsPlumb.setSourceEnabled(source, sourceFlag)
? ? ? ? this.jsPlumb.setTargetEnabled(target, targetFlag)
? ? ? ? this.jsPlumb.setDraggable(source, false) // 是否支持拖拽
? ? ? ? this.jsPlumb.setDraggable(target, false) // 是否支持拖拽
? ? ? },
? ? }
? }
</script>

<style>
? #container{
? ? width: 500px;
? ? height: 500px;
? ? padding: 20px;
? ? position: relative; /*一定加上這句,否則連線位置發(fā)生錯亂*/
? }

? .left{
? ? float: left;
? ? width: 150px;
? }
? .right{
? ? float: right;
? ? width: 150px;
? }

? .left li,.right li{
? ? width: 100%;
? ? border-radius: 4px;
? ? border: 1px solid #ccc;
? ? background: #efefef;
? ? margin-bottom: 20px;
? ? padding: 8px 5px;
? }
</style>

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • vue使用pdfjs-dist+fabric實現(xiàn)pdf電子簽章的思路詳解

    vue使用pdfjs-dist+fabric實現(xiàn)pdf電子簽章的思路詳解

    最近領(lǐng)導(dǎo)提了一個新需求:仿照e簽寶,實現(xiàn)pdf電子簽章,本文給大家介紹vue使用pdfjs-dist+fabric實現(xiàn)pdf電子簽章的思路,感興趣的朋友一起看看吧
    2023-12-12
  • elementUI Tree 樹形控件的官方使用文檔

    elementUI Tree 樹形控件的官方使用文檔

    這篇文章主要介紹了elementUI Tree 樹形控件的官方使用文檔,用清晰的層級結(jié)構(gòu)展示信息,可展開或折疊。小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2019-04-04
  • 教你用Cordova打包Vue項目的方法

    教你用Cordova打包Vue項目的方法

    這篇文章主要介紹了教你用Cordova打包Vue項目的方法,詳細(xì)的介紹了如何Vue項目打包成app,具有一定的參考價值,有興趣的可以了解一下
    2017-10-10
  • Vue.js組件高級特性實例詳解

    Vue.js組件高級特性實例詳解

    這篇文章主要介紹了Vue.js組件高級特性,結(jié)合實例形式詳細(xì)分析了vue.js組件遞歸、模板、動態(tài)加載、渲染等相關(guān)操作技巧,需要的朋友可以參考下
    2018-12-12
  • 關(guān)于vue3?解決getCurrentInstance?打包后線上環(huán)境報錯問題

    關(guān)于vue3?解決getCurrentInstance?打包后線上環(huán)境報錯問題

    這篇文章主要介紹了vue3?解決getCurrentInstance?打包后線上環(huán)境報錯問題,本文給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2022-05-05
  • vue中electron框架自定義外部配置文件的配置與讀取辦法

    vue中electron框架自定義外部配置文件的配置與讀取辦法

    使用Electron開發(fā)本地跨平臺的本地程序時,有時需要添加一些程序的配置文件,下面這篇文章主要給大家介紹了關(guān)于vue中electron框架自定義外部配置文件的配置與讀取的相關(guān)資料,需要的朋友可以參考下
    2023-12-12
  • Vue中獲取this.$refs為undefined的問題

    Vue中獲取this.$refs為undefined的問題

    這篇文章主要介紹了Vue中獲取this.$refs為undefined的問題,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2023-05-05
  • vue3.0運行npm run dev報錯Cannot find module node:url

    vue3.0運行npm run dev報錯Cannot find module&

    本文主要介紹了vue3.0運行npm run dev報錯Cannot find module node:url,因為使用的node版本是14.15.1低于15.0.0導(dǎo)致,具有一定的參考價值,感興趣的可以了解一下
    2023-10-10
  • VUE配置history路由模式配置詳細(xì)舉例

    VUE配置history路由模式配置詳細(xì)舉例

    這篇文章主要給大家介紹了關(guān)于VUE配置history路由模式配置的相關(guān)資料,History模式是Vue路由的另一種模式,在History模式下URL中的路徑不再使用#符號,而是直接使用正常的路徑形式,需要的朋友可以參考下
    2023-12-12
  • Vue3?<script?setup?lang=“ts“>?的基本使用

    Vue3?<script?setup?lang=“ts“>?的基本使用

    <script setup>?是在單文件組件 (SFC) 中使用?composition api?的編譯時語法糖,本文主要講解<script setup>?與?TypeScript?的基本使用,感興趣的朋友跟隨小編一起看看吧
    2022-12-12

最新評論

沅陵县| 英德市| 金华市| 湄潭县| 松桃| 启东市| 乐安县| 禄丰县| 台江县| 武隆县| 富裕县| 仁布县| 长岛县| 北海市| 合阳县| 交口县| 乐昌市| 将乐县| 北流市| 仙游县| 城口县| 新昌县| 阜新| 固阳县| 大石桥市| 长顺县| 武威市| 泸水县| 大厂| 都安| 拉孜县| 绥棱县| 思南县| 彰化县| 肥乡县| 甘孜县| 卓尼县| 年辖:市辖区| 凉城县| 修武县| 太谷县|