Web前端文档阅读笔记-vis.js在vue cli中的使用
生活随笔
收集整理的這篇文章主要介紹了
Web前端文档阅读笔记-vis.js在vue cli中的使用
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
程序運行截圖如下:
首先要用npm導入的vis包
npm run vis程序結構如下:
源碼如下:
HelloWorld.vue
<template><div id="networkDemo" style="width:800px; height: 600px"></div></template><script>import {createNode} from 'JS/visTest.js' export default {name: 'HelloWorld',mounted(){this.init();},data () {return {msg: 'Welcome to Your Vue.js App'}},methods: {init(){createNode('networkDemo')}} } </script><style scoped> </style>visTest.js
import vis from 'vis'export function createNode(idStr) {let nodes = new vis.DataSet([{id: 1, label: 'Node 1'},{id: 2, label: 'Node 2'},{id: 3, label: 'Node 3'},{id: 4, label: 'Node 4'},{id: 5, label: 'Node 5'},]);let edges = new vis.DataSet([{from: 1, to: 3, label: 'Hello'},{from: 1, to: 2},{from: 2, to: 4},{from: 2, to: 5},{from: 3, to: 5}])let container = document.getElementById(idStr);let data = {nodes: nodes,edges: edges};let options = {};let network = new vis.Network(container, data, options); }?
總結
以上是生活随笔為你收集整理的Web前端文档阅读笔记-vis.js在vue cli中的使用的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Qt笔记-使用正则表达式匹配URL及获取
- 下一篇: Qt工作笔记-WebEngineView