--- title: 安装 order: 1 --- ## npm ```bash # npm npm install @antv/g6 --save # pnpm pnpm add @antv/g6 # yarn yarn add @antv/g6 ``` 在代码中引入 G6: ```js import { Graph } from '@antv/g6'; ``` 访问 [G6 npm 示例](https://codesandbox.io/p/sandbox/using-g6-from-npm-d9spnr) 查看完整示例代码。 ## CDN `@antv/g6` 在多个 CDN 上提供: - unpkg: https://unpkg.com/@antv/g6@latest/dist/g6.min.js - jsDelivr: https://cdn.jsdelivr.net/npm/@antv/g6@5/dist/g6.min.js - npmmirror: https://registry.npmmirror.com/@antv/g6/5/files/dist/g6.min.js 使用 `script` 标签引入 G6: ```html ``` 访问 [G6 CDN 示例](https://codesandbox.io/p/sandbox/using-g6-from-cdn-xt9ty6) 查看完整示例代码。