Animate.css 在我的 Vue 3 项目中没有动画

问题描述

我只是想在我的 Vue 3 应用程序中做一些基本的 html 动画,但 Animate.css 示例不起作用。

特别是,在使用 npm install animate.css --save 安装动画 css 依赖项后,示例动画代码 <h1 class="animate__animated animate__bounce">An animated element</h1> 在我的页面加载时不会动画。标题呈现但只是坐在那里,一动不动。

我尝试过其他解决方案,例如 changing windows performanceadding animated to the class 等,但没有奏效。

我看到一些解决方案使用 CDN 来链接库,但我认为我不应该这样做,因为我使用 npm 来安装它。

我做错了什么?

<template>
  <div class="container-fluid" id="app">
    <h1 class="animate__animated animate__bounce" style="color:white">An animated element</h1>
  </div>
</template>

解决方法

将 animate.css 导入您的 main.js 文件

import 'animate.css';