vue中引用js_在Vue.js项目中使用Wow.js实现页面滚动动画

32e3ace3436aa931b3bf106f98154666.png
wow.js官网:
Reveal Animations When Scrolling​www.delac.io
942e0e501704a72c6ef019a855831165.png
wow.js GitHub地址:
https://github.com/matthieua/WOW​github.com

第一步:安装wow.js NPM包:

在命令行中执行:

npm install animate.css --save

第二步:引入及使用:

在main.js中引入:

// 省略部分代码
import wow from 'wowjs'
 
import 'animate.css'
 
Vue.prototype.$wow = wow
 
// 将wow挂载到Vue,这样我们可以在组件中通过this.$wow使用wow.js。
 
// 当然也可通过在组件中使用import wow from 'wowjs' 或者import {wow} from 'wowjs'来使用。

在vue页面中使用:

<!-- template -->
 
<div class="hello_world" >
    <section class="wow slideInLeft" data-wow-duration="1s" >
    </section>
        <section class="wow slideInLeft" data-wow-duration="2s" >
    </section> 
        <section class="wow slideInLeft" data-wow-duration="1s" >
    </section> 
        <section class="wow slideInLeft" data-wow-duration="2s" >
    </section> 
        <section class="wow slideInLeft" data-wow-duration="1s" >
    </section>
</div>
// script

export default {
  name:'Home',
  data() {
      return {
      }
  },
  mounted(){
      new this.$wow.WOW().init()
  }
}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值