导入 V4

Anime.js v4 API 公开了以下模块

导入方法

ES 模块

要使用 Anime.js 的 ES 模块语法导入,您可以使用如下所示的 import 语句

import {
  animate,
  createTimeline,
  createTimer,
  // ...other methods
} from 'animejs';

全局对象

您可以使用如下所示的 script 标签全局定义 Anime.js

<script src="path/to/anime.iife.min.js"></script>

然后直接从 anime 对象访问所有模块

anime.animate();
anime.createTimeline();
anime.createTimer();
// ...other methods

或者,您可以使用 对象解构 语法来模拟 ESM 导入语法,如下所示

const {
  animate,
  createTimeline,
  createTimer,
  // ...other methods
} = anime;