
vue LeaderLine 插件 元素连接线
vue
vuejs/vue: 是一个用于构建用户界面的 JavaScript 框架,具有简洁的语法和丰富的组件库,可以用于开发单页面应用程序和多页面应用程序。
项目地址:https://gitcode.com/gh_mirrors/vu/vue

·
官方文档:LeaderLine
1.安装插件
npm install leader-line-vue
2.导出LeaderLine
import LeaderLine from 'leader-line-vue';
3.创建连接线
let line = LeaderLine.setLine(startElement, endElement,
{ startPlug: 'disc', endPlug: 'disc',color: 'white', size: 2 });
注意:startElement, endElement为template中的元素节点,在Vue3中不要使用GetElementById去获取元素节点,而是要使用ref
4.刷新连接线
当元素位置变了时,需要更新连接线
line.position();
5.效果
6.代码
<template>
<div id="cesiumContainer">
<div ref="startRef" id="start">start</div>
<div ref="endRef" id="end">end</div>
</div>
</template>
<script>
import LeaderLine from 'leader-line-vue';
export default {
data(){
return{
}
},
mounted() {
this.&nextTick(()=>{
LeaderLine.setLine(document.getElementById('start'),
document.getElementById('end'));
})
},
methods:{
}
}
</script>
<style scoped>
#cesiumContainer
{
width: 100%;
height: 100%;
}
#start {
width: 50px;
height: 50px;
position: absolute;
top:10px;
left: 10px;
background-color: red;
}
#end {
width: 50px;
height: 50px;
position: absolute;
top:200px;
left: 200px;
background-color: red;
}
</style>




vuejs/vue: 是一个用于构建用户界面的 JavaScript 框架,具有简洁的语法和丰富的组件库,可以用于开发单页面应用程序和多页面应用程序。
最近提交(Master分支:6 个月前 )
9e887079
[skip ci] 4 个月前
73486cb5
* chore: fix link broken
Signed-off-by: snoppy <michaleli@foxmail.com>
* Update packages/template-compiler/README.md [skip ci]
---------
Signed-off-by: snoppy <michaleli@foxmail.com>
Co-authored-by: Eduardo San Martin Morote <posva@users.noreply.github.com> 8 个月前
更多推荐
所有评论(0)