首先需要在vue环境下安装 jointjs 和 jquery
npm install jquery --save
npm install jointjs
以下就是在vue中使用 jointjs 3.x 创建自定义html节点的代码, 以下代码可以在vue中正常运行
<template>
<div id="paper-html-elements" ref="canvas"></div>
</template>
<script>
import $ from 'jquery';
import * as joint from 'jointjs';
window.joint = joint;
export default {
data() {
return {
paper: null,
customDivContent: '', // 自定义html内容的容器
};
},
mounted() {
this.init();
},
methods: {
init() {
let namespace = joint.shapes;
let graph = new joint.dia.Graph({}, { cellNamespace: namespace });
this.parper &#