分别介绍vue2.x和vue3.x使用gojs的方法
vue2.x使用gojs
安装:
npm install --save gojs
引用:main.js 里
import gojs from 'gojs'
Vue.prototype.go = gojs
使用:
let go = this.go;
let $ = go.GraphObject.make;
myDiagram = $(go.Diagram, myDiagramDiv ,{......}) // 必须命名或引用div HTML元素
vue3.x使用gojs
下面介绍两种使用方法,推荐使用第二种
第一种方法:
安装:
npm install --save gojs
引用:main.ts 里
import gojs from 'gojs'
createApp(App,{go:gojs}).use(router).use(store).mount('#app')
在当前页面中使用:
//定义prop接收
const props = defineProps({
go: Object
})
const init = ()=>{
let go = props.go;
let $ = go.GraphObject.make;
myDiagram = $(go.Diagram, myDiagramDiv ,{......}) // 必须命名或引用div HTML元素
}
第二种方法(推荐):
安装:
npm install --save gojs
在当前页面中使用:
import * as go from 'gojs';
const init = ()=>{
let $ = go.GraphObject.make;
myDiagram = $(go.Diagram, myDiagramDiv ,{......}) // 必须命名或引用div HTML元素
}