leafer-ui

在 Web 环境中运行。

同时我们提供了一个 体验环境,方便大家体验官网示例、阅读源代码。

安装

npm

  1. npm install leafer-ui

pnpm

  1. pnpm add leafer-ui

yarn

  1. yarn add leafer-ui

bun

  1. bun add leafer-ui

浏览器引入

web.minwebmodule.minmodule

  1. <script src="https://unpkg.com/leafer-ui@1.0.0/dist/web.min.js"></script>
  2. <script>
  3. const { Leafer } = LeaferUI
  4. // ...
  5. </script>
  1. <script src="https://unpkg.com/leafer-ui@1.0.0/dist/web.js"></script>
  2. <script>
  3. const { Leafer } = LeaferUI
  4. // ...
  5. </script>
  1. <script type="module">
  2. import { Leafer } from 'https://unpkg.com/leafer-ui@1.0.0/dist/web.module.min.js'
  3. // ...
  4. </script>
  1. <script type="module">
  2. import { Leafer } from 'https://unpkg.com/leafer-ui@1.0.0/dist/web.module.js'
  3. // ...
  4. </script>

https://unpkg.com 无法访问时,可替换为 https://cdn.jsdelivr.net/npm

浏览器环境

需要支持 ES2015 语法。

体验环境

想直接运行官网示例代码,可以 安装体验环境

开始体验

创建一个交互应用,可以缩放平移视图、拖拽矩形。

  1. import { Leafer, Rect } from 'leafer-ui'
  2. const leafer = new Leafer({ view: window })
  3. const rect = new Rect({
  4. x: 100,
  5. y: 100,
  6. width: 200,
  7. height: 200,
  8. fill: '#32cd79',
  9. cornerRadius: [50, 80, 0, 80],
  10. draggable: true
  11. })
  12. leafer.add(rect)