博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
vue引入mxGrpah
阅读量:6863 次
发布时间:2019-06-26

本文共 856 字,大约阅读时间需要 2 分钟。

第一步:下载npm包

npm install mxgraph --save复制代码

第二步:新建一个index.js文件

文件内容如下

import mx from 'mxgraph';const mxgraph = mx({  mxImageBasePath: './src/images',  mxBasePath: './src'});// decode bug https://github.com/jgraph/mxgraph/issues/49window.mxGraph = mxgraph.mxGraph;window.mxGraphModel = mxgraph.mxGraphModel;window.mxEditor = mxgraph.mxEditor;window.mxGeometry = mxgraph.mxGeometry;window.mxDefaultKeyHandler = mxgraph.mxDefaultKeyHandler;window.mxDefaultPopupMenu = mxgraph.mxDefaultPopupMenu;window.mxStylesheet = mxgraph.mxStylesheet;window.mxDefaultToolbar = mxgraph.mxDefaultToolbar;export default mxgraph;复制代码

这个是官方引入的方法。它将返回一个接受对象作为选析那个的工厂函数。必须将mxBasePath选项提供给工厂函数,而不是将其定义为一个全局变量。 在vue使用时方法的指向会发生变化,所以将其挂载到window上。

第三步:在index.vue或其他文件中引入

import mxgraph from 'index.js';const {mxGraph, mxClient, mxCodec, mxUtils, mxConstants, mxPerimeter} = mxgraph;复制代码

转载地址:http://zdeyl.baihongyu.com/

你可能感兴趣的文章
log4j2的配置文件log4j2.xml笔记
查看>>
Android中文API (110) —— CursorTreeAdapter
查看>>
Windows Server 2008 with hyper-V 支持的 Guest OS
查看>>
头脑风暴-如何减少软件项目对于人的依赖性。
查看>>
了解 NoSQL 的必读资料
查看>>
空瓶换酒问题
查看>>
swift UI专项训练5 定制视图控制器
查看>>
格式化字符串,固定宽度字符串,不足用空格填补
查看>>
SharePoint Server 2016 部署安装(三)—— 安装SharePoint Server
查看>>
弱引用研究
查看>>
Exchange 2007 的邮件监控器
查看>>
db2中的几个转义字符
查看>>
Android:ListView、ListActivity、 setListAdapter
查看>>
VMM系列之使用VMM服务器构建 Hyper-V主机(2)
查看>>
搭建本地YUM源服务器
查看>>
图解Oracle备份方式分类
查看>>
数组、哈希以及其他枚举类型
查看>>
exchange OWA 用户自行更改密码
查看>>
Microsoft Dynamics server 2015 所有的SQL server 2012 视图 介绍及功能
查看>>
Oracle备份恢复一(手动备份)
查看>>