本篇文章為大家展示了怎么在vue中利用vis-network 實現網絡拓撲圖,內容簡明扼要并且容易理解,絕對能使你眼前一亮,通過這篇文章的詳細介紹希望你能有所收獲。
創新互聯公司 - 四川雅安電信機房,四川服務器租用,成都服務器租用,四川網通托管,綿陽服務器托管,德陽服務器托管,遂寧服務器托管,綿陽服務器托管,四川云主機,成都云主機,西南云主機,四川雅安電信機房,西南服務器托管,四川/成都大帶寬,機柜大帶寬,四川老牌IDC服務商
vs code 下安裝命令
npm install vis-network
在vue 下引入 vis-network組件
const vis = require("vis-network/dist/vis-network.min.js"); require("vis-network/dist/vis-network.min.css");
例子代碼使用
let DIR = "/jtopo/"; let nodes = [ { id: 1, shape: "circularImage", image: DIR + "server.png" }, { id: 2, shape: "circularImage", image: DIR + "server.png" }, { id: 3, shape: "circularImage", image: DIR + "server.png" }, { id: 4, shape: "circularImage", image: DIR + "gather.png", label: "pictures by this guy!" }, { id: 5, shape: "circularImage", image: DIR + "wanjet.png" }, { id: 6, shape: "circularImage", image: DIR + "center.png" }, { id: 7, shape: "circularImage", image: DIR + "cloud.png" }, { id: 8, shape: "circularImage", image: DIR + "center.png" }, { id: 9, shape: "circularImage", image: DIR + "wanjet.png" }, { id: 10, shape: "circularImage", image: DIR + "gather.png" } // { id: 11, shape: "circularImage", image: DIR + "11.png" }, // { id: 12, shape: "circularImage", image: DIR + "12.png" }, // { id: 13, shape: "circularImage", image: DIR + "13.png" }, // { id: 14, shape: "circularImage", image: DIR + "14.png" }, // { // id: 15, // shape: "circularImage", // image: DIR + "missing.png", // brokenImage: DIR + "missingBrokenImage.png", // label: "when images\nfail\nto load" // }, // { // id: 16, // shape: "circularImage", // image: DIR + "anotherMissing.png", // brokenImage: DIR + "9.png", // label: "fallback image in action" // } ]; let edges = [ { from: 1, to: 4 }, { from: 2, to: 4 }, { from: 3, to: 4 }, { from: 4, to: 5 }, { from: 5, to: 6 }, { from: 6, to: 7 }, { from: 8, to: 7 }, { from: 9, to: 8 }, { from: 10, to: 9 } // { from: 8, to: 10 }, // { from: 10, to: 11 }, // { from: 11, to: 12 }, // { from: 12, to: 13 }, // { from: 13, to: 14 }, // { from: 9, to: 16 } ]; for (let i = 1; i <= 100; i++) { num = i + 10; nodes.push({ id: num, label: num.toString() }); edges.push({ from: num, to: 10 }); } let data = { nodes: nodes, edges: edges }; let container = document.getElementById("mynetwork"); //let options = {}; let options = { nodes: { font: { color: "white", //字體的顏色 size: 30 //顯示字體大小 }, scaling: { min: 16, max: 32 //縮放效果比例 }, borderWidth: 0, color: { border: "white", background: "white" //若是引用圖標,背景顏色 } }, groups: { ws: { //系統定義的形狀 dot等 這些官網都可以找到 shape: "dot", color: "white" } }, edges: { //連接線的樣式 color: { color: "white", highlight: "white", hover: "#848484", inherit: "from", opacity: 1.0 } }, layout: { randomSeed: 1 //配置每次生成的節點位置都一樣,參數為數字1、2等 }, physics: { // barnesHut: { gravitationalConstant: -30000 }, barnesHut: { gravitationalConstant: -80000, springConstant: 0.001, springLength: 200 }, stabilization: false //{ iterations: 2500 } }, interaction: { // navigationButtons: true, hover: true, //鼠標移過后加粗該節點和連接線 selectConnectedEdges: false, //選擇節點后是否顯示連接線 hoverConnectedEdges: false, //鼠標滑動節點后是否顯示連接線 tooltipDelay: 200, zoomView: true //是否能縮放畫布 }, edges: { shadow: true, //連接線陰影配置 smooth: true //是否顯示方向箭頭 // arrows: {to : true }//箭頭指向from節點 } }; that.network = new vis.Network(container, data, options); that.network.on("click", function(params) {});
Vue是一套用于構建用戶界面的漸進式JavaScript框架,Vue與其它大型框架的區別是,使用Vue可以自底向上逐層應用,其核心庫只關注視圖層,方便與第三方庫和項目整合,且使用Vue可以采用單文件組件和Vue生態系統支持的庫開發復雜的單頁應用。
上述內容就是怎么在vue中利用vis-network 實現網絡拓撲圖,你們學到知識或技能了嗎?如果還想學到更多技能或者豐富自己的知識儲備,歡迎關注創新互聯行業資訊頻道。
文章標題:怎么在vue中利用vis-network實現網絡拓撲圖
標題網址:http://m.newbst.com/article24/ppisce.html
成都網站建設公司_創新互聯,為您提供靜態網站、自適應網站、關鍵詞優化、企業建站、網站建設、Google
聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯