vue 中使用wow.js

wow.js可以在页面向下滚动时加载css动画,并且可以触发animate.css的动画效果。

wow.jsGitHub地址:https://github.com/matthieua/WOW

wow.js官网:https://www.delac.io/wow/docs.html

在vue中使用:

首先install:

npm install wowjs --save

执行完该操作之后animate.css也可以使用了

在main.js中引入

import wow from 'wowjs'

import 'animate.css'

main.js再加入Vue.prototype.$wow=wow,这样我们可以在组件中通过this.$wow使用wow.js

当然也可通过在组件中使用import wow from 'wowjs' 或者import {wow} from 'wowjs'来使用。

一个vue组件列子:

<template>

<div class="test_wow" >

    <section class="wow slideInLeft test_wow" data-wow-duration="1s" >

    </section>

        <section class="wow slideInLeft test_wow1" data-wow-duration="2s" >

    </section> 

        <section class="wow slideInLeft test_wow2" data-wow-duration="1s" >

    </section> 

        <section class="wow slideInLeft test_wow3" data-wow-duration="2s" >

    </section> 

        <section class="wow slideInLeft test_wow4" data-wow-duration="1s" >

    </section>       

</div>


</template>

<script>

export default {

    name:'Home',

  data() {

      return {

      }

  },

  mounted(){

      new  this.$wow.WOW().init()

  }

}

</script>

<style scoped>

.test_wow{

    position: relative;

    width: 1000px;

    height: 400px;

    background: #212121;

    margin: 0 auto;

}

.test_wow1{

    position: relative;

    width: 1000px;

    height: 400px;

    background: #741919;

    margin: 0 auto;

}

.test_wow2{

    position: relative;

    width: 1000px;

    height: 400px;

    background: #2b0f44;

    margin: 0 auto;

}

.test_wow3{

    position: relative;

    width: 1000px;

    height: 400px;

    background: #558614;

    margin: 0 auto;

}

.test_wow4{

    position: relative;

    width: 1000px;

    height: 400px;

    background: #440707;

    margin: 0 auto;

}

</style>


完整列子:https://gitee.com/cheng1225/vue-wow

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 1. tab列表折叠效果 html: 能源系统事业部 岗位名称: 工作地点 岗位名...
    lilyping阅读 5,875评论 0 1
  • 各种纯css图标 CSS3可以实现很多漂亮的图形,我收集了32种图形,在下面列出。直接用CSS3画出这些图形,要比...
    剑残阅读 13,239评论 0 8
  • 不会用代码框,所以看着有些乱套,,,,html部分 <!DOCTYPE html> 迅雷看看 ...
    这就是个帅气的名字阅读 5,438评论 0 0
  • 听众里很多是想开店的朋友,听了节目后感觉很有用处,但是跟我聊又不知道从哪里开始聊,通常第一个问题是:我很迷茫,怎么...
    开店笔记阅读 5,603评论 1 5
  • 年年岁岁假相似,岁岁年年人不同。一年一度的寒假已经来临,我们中国的家长早早就替孩子安排好寒假计划,他们认为假期是对...
    禹音阅读 2,976评论 0 0