使用leaderLine插件以及问题总结
(1)npm i leader-line -S
将leader-line.main.js复制到项目中并在结尾写:exportDefault LeaderLine
(2)创建公共函数createLine
路径: src/utils/createLine.js
import LeaderLine from './plugins/leader-line.min'
export function createLine(startEle,endEle,styleOption{
return new LeaderLine(startEle,endEle,{
...styleOption
})
}
(3)在页面调用createLine()
import {createLine} from '@/utils/createLine.js'
mounted(){
setTimeout(() => {
this.getLine()
},50);
},
methods:{
getLine() {
let startEle1 = document.getElementById('start1')
let endEle1 = document.getElementById('end1')
this.line1 = createLine(startEle1,endEle1,{
color:'#3E5C73',
size: 2,
startSocket: 'rigth', //在