vue
:::warning Please do not pass Vue reactive data directly to the G6 instance, which may cause G6 to fail to render correctly, or even cause the page to crash. :::
Refer to the example below, you can use G6 in Vue, and you can also view the Live Example。
<template>
<div id="container"></div>
</template>
<script setup>
import { onMounted } from 'vue';
import { Graph } from '@antv/g6';
onMounted(() => {
const graph = new Graph({
container: document.getElementById('container'),
width: 500,
height: 500,
data: {
nodes: [
{
id: 'node-1',
style: { x: 50, y: 100 },
},
{
id: 'node-2',
style: { x: 150, y: 100 },
},
],
edges: [{ id: 'edge-1', source: 'node-1', target: 'node-2' }],
},
});
graph.render();
});
</script>