1.安装wowjs 和 animate.css
npm install wowjs
npm install animate.css
2.在nuxt.config.js引入animate.css

css: [
'animate.css/animate.css'
]
3.在需要用到wowjs页面
if (process.browser) { // 在这里根据环境引入wow.js
var {
WOW
} = require('wowjs')
}
export default {
name: 'IndexPage',
mounted() {
if (process.browser) { // 在页面mounted生命周期里面 根据环境实例化WOW
new WOW({
live: false,
offset: 0
}).init()
}
}
}
4. 使用
<div class="animate__animated animate__fadeInLeft wow">
wowjs Animate.css
</div>
animate.css官网文档以及展示案例
文章介绍了如何在项目中安装和使用Wowjs及Animate.css库。首先通过npm安装这两个依赖,然后在nuxt.config.js中引入animate.css。在需要动画效果的页面中,根据浏览器环境实例化Wowjs,并在mounted生命周期钩子中初始化。最后,通过给元素添加特定类名实现动画效果,如`fadeInLeft`。
745

被折叠的 条评论
为什么被折叠?



