导出XML文件
先获取mxGraph的xml字符串,getPrettyXml相比getXml有格式化;然后生成a标签下载即可
const encoder = new mxgraph.mxCodec()
const node = encoder.encode(this.graph.getModel())
const xml = mxgraph.mxUtils.getPrettyXml(node)
const downLink = document.createElement('a')
downLink.download = 'graph.xml'
const blob = new Blob([xml])
downLink.href = URL.createObjectURL(blob)
document.body.appendChild(downLink)
downLink.click()
document.body.removeChild(downLink)
导出XML文件
template
使用了element的upload做文件选择,自定义input类型为file也可以
<el-upload
:auto-upload="false"
:show-file-list="false"
action=""
:on-change="handleImport"
>
<a class="tex