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

vue3.x 使用jsplumb實現(xiàn)拖拽連線

 更新時間:2022年03月29日 17:07:05   作者:qq_37656005  
這篇文章主要為大家詳細介紹了vue3.x 使用jsplumb實現(xiàn)拖拽連線,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實例為大家分享了vue3.x 使用jsplumb實現(xiàn)拖拽連線的具體代碼,供大家參考,具體內(nèi)容如下

如果想在vue2里面使用jsplumb 可以查看 文章,下面講解如何在vue3.x 里面使用jsplumb進行拖拽連線

1、安裝

npm install --save jsplumb

2、引入

<script lang="ts" setup>
? import {ref, reactive,onMounted} from 'vue'
? import jsPlumb from 'jsplumb'
</script>

3、使用

<template>
? <h3>jsplumb使用</h3>
? <div id="container">
? ? ? ? <div class="col1">
? ? ? ? ? ? <div v-for="item in list1" :key="item.nodeId" :id="item.nodeId" name="joint">{{ item.name }}</div>
? ? ? ? </div>
? ? ? ? <div class="col2">
? ? ? ? ? ? <div v-for="item in list2" :key="item.nodeId" :id="item.nodeId" name="data">{{ item.name }}</div>
? ? ? ? </div>
? ? </div>
</template>
<script lang="ts" setup>
? import {ref, reactive,onMounted} from 'vue'
? import jsPlumb from 'jsplumb'
? ? //jsplumb使用
? ? let $jsPlumb = jsPlumb.jsPlumb;
? ? let jsPlumb_instance = null; // 緩存實例化的jsplumb對象
? ? //模型軸
? ? const list1 = reactive([
? ? ? ? {name: "name1", nodeId: "name1", axis: '', type:''},
? ? ? ? {name: "name2", nodeId: "name2", axis: '', type:''},
? ? ? ? {name: "name3", nodeId: "name3", axis: '', type:''},
? ? ? ? {name: "name4", nodeId: "name4", axis: '', type:''},
? ? ? ? {name: "name5", nodeId: "name5", axis: '', type:''},
? ? ? ? {name: "name6", nodeId: "name6", axis: '', type:''}
? ? ]);
? ? //接口數(shù)據(jù)點
? ? const list2 = reactive([
? ? ? ? {name: '數(shù)據(jù)1', nodeId: 'data1'},
? ? ? ? {name: '數(shù)據(jù)2', nodeId: 'data2'},
? ? ? ? {name: '數(shù)據(jù)3', nodeId: 'data3'},
? ? ? ? {name: '數(shù)據(jù)4', nodeId: 'data4'},
? ? ? ? {name: '數(shù)據(jù)5', nodeId: 'data5'},
? ? ? ? {name: '數(shù)據(jù)6', nodeId: 'data6'}
? ? ]);

? ? onMounted(()=>{
? ? ? ? showPlumb();
? ? })

? ? const showPlumb = ()=> {
? ? ? ? jsPlumb_instance = $jsPlumb.getInstance({
? ? ? ? ? ? Container: 'container', // 選擇器id
? ? ? ? ? ? EndpointStyle: {radius: 0.11, fill: '#fff'}, // 端點樣式
? ? ? ? ? ? PaintStyle: {stroke: '#000', strokeWidth: 2}, // 繪畫樣式,默認8px線寬 ?#456
? ? ? ? ? ? HoverPaintStyle: {stroke: '#1E90FF'}, // 默認懸停樣式 ?默認為null
? ? ? ? ? ? ConnectionOverlays: [ // 此處可以設(shè)置所有箭頭的樣式,因為我們要改變連接線的樣式,故單獨配置
? ? ? ? ? ? ? ? ['Arrow', { // 設(shè)置參數(shù)可以參考中文文檔
? ? ? ? ? ? ? ? ? ? location: 1,
? ? ? ? ? ? ? ? ? ? length: 10,
? ? ? ? ? ? ? ? ? ? paintStyle: {
? ? ? ? ? ? ? ? ? ? ? ? stroke: '#000',
? ? ? ? ? ? ? ? ? ? ? ? fill: '#000'
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? }]
? ? ? ? ? ? ],
? ? ? ? ? ? Connector: ['Straight'], // 要使用的默認連接器的類型:直線,折線,曲線等
? ? ? ? ? ? DrapOptions: {cursor: 'crosshair', zIndex: 2000}
? ? ? ? },)

? ? ? ? console.log(jsPlumb_instance)

? ? ? ? jsPlumb_instance.batch(() => {

? ? ? ? ? ? for (let i = 0; i < list1.length; i++) {
? ? ? ? ? ? ? ? initLeaf(list1[i].nodeId, 'joint')
? ? ? ? ? ? }
? ? ? ? ? ? for (let i = 0; i < list2.length; i++) {
? ? ? ? ? ? ? ? initLeaf(list2[i].nodeId, 'data')
? ? ? ? ? ? }
? ? ? ? })

? ? ? ? const joint = document.getElementsByName('joint')
? ? ? ? const data = document.getElementsByName('data')

? ? ? ? jsPlumb_instance.setSourceEnabled(joint, true)
? ? ? ? jsPlumb_instance.setTargetEnabled(data, true)
? ? ? ? jsPlumb_instance.setDraggable(joint, false) // 是否支持拖拽
? ? ? ? jsPlumb_instance.setDraggable(data, false) // 是否支持拖拽

? ? ? ? jsPlumb_instance.bind('click', ?(conn, originalEvent) => {
? ? ? ? ? ? jsPlumb_instance.deleteConnection(conn)
? ? ? ? })

? ? }

? ? // 初始化具體節(jié)點
? ? const initLeaf = (id, type)=> {
? ? ? ? const ins = jsPlumb_instance;
? ? ? ? const elem = document.getElementById(id)
? ? ? ? if (type == 'joint') {
? ? ? ? ? ? ins.makeSource(elem, {
? ? ? ? ? ? ? ? anchor: [1, 0.5, 0, 0], // 左 上 右 下
? ? ? ? ? ? ? ? allowLoopback: false,
? ? ? ? ? ? ? ? maxConnections: 1
? ? ? ? ? ? })
? ? ? ? } else {
? ? ? ? ? ? ins.makeTarget(elem, {
? ? ? ? ? ? ? ? anchor: [0, 0.5, 0, 0],
? ? ? ? ? ? ? ? allowLoopback: false,
? ? ? ? ? ? ? ? maxConnections: 1
? ? ? ? ? ? })
? ? ? ? }
? ? }

</script>

<style scoped lang="less">
?#container {
? ? position: relative;
? ? ? margin-top: 20px;
? ? ? width: 100%;
? ? ? height: 300px;
? }

? .col2, .col1 {
? ? ? float: left;
? ? ? text-align: center;
? }

? .col1 {
? ? ? width: 80px;
? }

? .col2 {
? ? ? width: 120px;
? ? ? margin-left: 80px;
? }

? #container > div > div {
? ? ? line-height: 30px;
? ? ? margin: 0 0 17px 0;
? ? ? background: #ef631e;
? ? ? color: #fff;
? }
</style>

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

相關(guān)文章

  • 詳解Vue3?父組件調(diào)用子組件方法($refs?在setup()、<script?setup>?中使用)

    詳解Vue3?父組件調(diào)用子組件方法($refs?在setup()、<script?setup>?中使用)

    這篇文章主要介紹了Vue3?父組件調(diào)用子組件方法($refs?在setup()、<script?setup>?中使用),在 vue2 中 ref 被用來獲取對應(yīng)的子元素,然后調(diào)用子元素內(nèi)部的方法,本文通過實例代碼給大家介紹的非常詳細,需要的朋友可以參考下
    2022-08-08
  • VUE如何實現(xiàn)點擊文字添加顏色(動態(tài)修改class)

    VUE如何實現(xiàn)點擊文字添加顏色(動態(tài)修改class)

    這篇文章主要介紹了VUE如何實現(xiàn)點擊文字添加顏色(動態(tài)修改class),具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2023-11-11
  • vue實現(xiàn)頁面打印自動分頁的兩種方法

    vue實現(xiàn)頁面打印自動分頁的兩種方法

    這篇文章主要為大家詳細介紹了vue實現(xiàn)頁面打印自動分頁的兩種方法,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2021-09-09
  • Vue數(shù)據(jù)雙向綁定的實現(xiàn)方式講解

    Vue數(shù)據(jù)雙向綁定的實現(xiàn)方式講解

    Vue數(shù)據(jù)雙向綁定原理:Vue內(nèi)部通過Object.defineProperty方法屬性攔截的方式,把data對象里每個數(shù)據(jù)的讀寫轉(zhuǎn)化成getter/setter,當(dāng)數(shù)據(jù)變化時通知視圖更新
    2022-08-08
  • Vue3全局掛載使用Axios學(xué)習(xí)實戰(zhàn)

    Vue3全局掛載使用Axios學(xué)習(xí)實戰(zhàn)

    這篇文章主要為大家介紹了Vue3全局掛載使用Axios學(xué)習(xí)實戰(zhàn)示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪
    2022-06-06
  • 淺談一下Vue生命周期中mounted和created的區(qū)別

    淺談一下Vue生命周期中mounted和created的區(qū)別

    每一個vue實例從創(chuàng)建到銷毀的過程,就是這個vue實例的生命周期,在這個過程中,他經(jīng)歷了從開始創(chuàng)建、初始化數(shù)據(jù)、編譯模板、掛載Dom、渲染→更新→渲染、卸載等一系列過程,那么這些過程中,具體vue做了些啥,我們今天來了解一下
    2023-05-05
  • 解決vue同一slot在組件中渲染多次的問題

    解決vue同一slot在組件中渲染多次的問題

    今天小編就為大家分享一篇解決vue同一slot在組件中渲染多次的問題,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2018-09-09
  • vue組件通信傳值操作示例

    vue組件通信傳值操作示例

    這篇文章主要介紹了vue組件通信傳值操作,結(jié)合實例形式分析了vue.js父子組件通信及兄弟組件通信相關(guān)操作技巧,需要的朋友可以參考下
    2019-01-01
  • Vue使用Axios進行跨域請求的方法詳解

    Vue使用Axios進行跨域請求的方法詳解

    在開發(fā)現(xiàn)代?Web?應(yīng)用時,前端和后端通常分離部署在不同的服務(wù)器上,這就會引發(fā)跨域請求問題,所以本文將詳細介紹如何在?Vue?項目中使用?Axios?發(fā)起跨域請求時解決跨域問題的相關(guān)資料,需要的朋友可以參考下
    2024-09-09
  • 一文搞懂vue中provide和inject實現(xiàn)原理對抗平庸

    一文搞懂vue中provide和inject實現(xiàn)原理對抗平庸

    這篇文章主要為大家介紹了vue中provide和inject實現(xiàn)原理的深入理解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪
    2023-04-04

最新評論

剑川县| 乡宁县| 东阳市| 固镇县| 永康市| 宝兴县| 芮城县| 荆门市| 瑞昌市| 岗巴县| 家居| 子长县| 顺义区| 清原| 大同市| 木兰县| 余江县| 健康| 通化市| 东乡| 湖州市| 政和县| 莱州市| 宽甸| 宝山区| 昌图县| 敦化市| 天柱县| 道孚县| 亳州市| 米泉市| 贞丰县| 阿坝| 边坝县| 普陀区| 南涧| 崇信县| 西平县| 青河县| 唐河县| 金堂县|