最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Vue-cli3生成的Vue項目加載Mxgraph方法示例

 更新時間:2020年05月31日 10:18:47   作者:懶牛不愛梳毛  
這篇文章主要介紹了Vue-cli3生成的Vue項目加載Mxgraph方法示例,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧

使用Vue-cli3生成Vue項目,并等待項目創(chuàng)建成功。

vue create [項目名]

安裝mxgraph。

cnpm install mxgraph --save

安裝exports-loader。

cnpm install exports-loader --save

安裝script-loader。

cnpm install script-loader --save

在項目根目錄新建vue.config.js文件。

將以下內(nèi)容復(fù)制到vue.config.js文件中。

const path = require('path');

function resolve(dir) {
  return path.join(__dirname, dir);
}

module.exports = {
  publicPath: './',
  outputDir: 'dist',
  lintOnSave: true,
  chainWebpack: (config) => {
    config.module
      .rule('')
      .test(/mxClient\.js$/)
      .use('exports-loader')
      .loader('exports-loader?mxClient,mxGraphModel,mxActor,mxShape,mxEventObject,mxGraph,mxPrintPreview,mxEventSource,mxRectangle,mxVertexHandler,mxMouseEvent,mxGraphView,mxImage,mxGeometry,mxRubberband,mxKeyHandler,mxDragSource,mxGraphModel,mxEvent,mxUtils,mxWindow,mxEvent,mxCodec,mxCell,mxConstants,mxPoint,mxGraphHandler,mxCylinder,mxCellRenderer,mxEvent,mxUndoManager')
      .end();
    config.resolve.alias
      .set('@', resolve('src'))
      .set('@assets', resolve('src/assets'));
    // 按這種格式.set('', resolve('')) 自己添加
  }
};

修改HelloWorld.vue,替換為以下內(nèi)容。

<template>
  <div ref="graph_container"></div>
</template>

<script>
import {
  mxGraph
} from 'mxgraph/javascript/mxClient';

export default {
  name: 'HelloWorld',
  props: {
    msg: String
  },
  mounted() {
    // Creates the graph inside the given container
    var graph = new mxGraph(this.$refs.graph_container);

    // Gets the default parent for inserting new cells. This
    // is normally the first child of the root (ie. layer 0).
    var parent = graph.getDefaultParent();

    // Adds cells to the model in a single step
    graph.getModel().beginUpdate();
    try {
      let v1 = graph.insertVertex(parent, null, 'Hello,', 20, 20, 80, 30);
      let v2 = graph.insertVertex(parent, null, 'World!', 200, 150, 80, 30);

      graph.insertEdge(parent, null, '', v1, v2);
    } finally {
      // Updates the display
      graph.getModel().endUpdate();
    }
  }
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h3 {
  margin: 40px 0 0;
}

ul {
  list-style-type: none;
  padding: 0;
}

li {
  display: inline-block;
  margin: 0 10px;
}

a {
  color: #42b983;
}
</style>

運行項目,查看效果。此Demo的源碼可以查看

到此這篇關(guān)于Vue-cli3生成的Vue項目加載Mxgraph方法示例的文章就介紹到這了,更多相關(guān)Vue項目加載Mxgraph內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評論

屏边| 阳西县| 台南市| 泰州市| 雅江县| 宁城县| 新晃| 宁强县| 宁都县| 繁昌县| 龙南县| 许昌市| 蒲城县| 佛教| 阜南县| 石棉县| 依安县| 健康| 泸定县| 龙岩市| 临安市| 昌宁县| 隆回县| 林西县| 西畴县| 霍州市| 绍兴县| 美姑县| 彩票| 新巴尔虎右旗| 肥西县| 香格里拉县| 秦皇岛市| 蒙自县| 本溪市| 吉木萨尔县| 铁力市| 乌什县| 宿松县| 环江| 克东县|