vue-vue2脚手架11-Vue封装的与动画过度(animate.css)

vue-vue2脚手架11-Vue封装的与动画过度

  1. 作用:在插入、更新或移除 DOM元素时,在合适的时候给元素添加样式类名。

  2. 图示在这里插入图片描述

  3. 写法:

    1. 准备好样式:

      • 元素进入的样式:
        1. v-enter:进入的起点
        2. v-enter-active:进入过程中
        3. v-enter-to:进入的终点
      • 元素离开的样式:
        1. v-leave:离开的起点
        2. v-leave-active:离开过程中
        3. v-leave-to:离开的终点
    2. 使用<transition>包裹要过度的元素,并配置name属性:

      <transition name="hello">
      	<h1 v-show="isShow">你好啊!</h1>
      </transition>
      
    3. 备注:若有多个元素需要过度,则需要使用:<transition-group>,且每个元素都要指定key值。

  4. 引入animate.css 动画效果

    1. npm install animate.css
    2. vue引入:import ‘animate.css’

MyList.vue

 这里用的是 transition-group,因为是多条数据
<template>

   <ul class="todo-main">
	<transition-group name="todo" appear>
    <MyItem 
	v-for="todoObj in todos" :key="todoObj.id"  
	:todo="todoObj" 
    :deleteTodo="deleteTodo"
	/>
	</transition-group>
   </ul>

</template>

<script>
    import MyItem from './MyItem'
	export default {
		name:'MyList',
		components:{MyItem},
		props:['todos','deleteTodo'],
	
	}
</script>


<style scoped>
	/*main*/
	.todo-main {
		margin-left: 0px;
		border: 1px solid #ddd;
		border-radius: 2px;
		padding: 0px;
	}

	.todo-empty {
		height: 40px;
		line-height: 40px;
		border: 1px solid #ddd;
		border-radius: 2px;
		padding-left: 5px;
		margin-top: 10px;
	}
	.todo-enter-active{
		animation: atguigu 0.5s linear;
	}

	.todo-leave-active{
		animation: atguigu 0.5s linear reverse;
	}

	@keyframes atguigu {
		from{
			transform: translateX(100%);
		}
		to{
			transform: translateX(0px);
		}
	}
</style>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Vue-Animate-CSS 是一个 Vue.js 的插件,它可以让你很容易地在 Vue.js 应用中使用 Animate.css 动画库。 要使用 Vue-Animate-CSS,首先需要安装它。你可以通过 npm 安装: ``` npm install vue-animate-css --save ``` 安装完成后,将其添加到你的 Vue.js 应用中。在 main.js 文件中添加以下代码: ```javascript import Vue from 'vue' import VueAnimateCss from 'vue-animate-css' Vue.use(VueAnimateCss) ``` 现在,你可以在 Vue.js 组件中使用 Vue-Animate-CSS 了。假设你想要为某个元素添加 Animate.css 中的 "bounce" 动画,你可以这样写: ```html <template> <div class="animated bounce"> Hello World! </div> </template> ``` 这里的 "animated" 是 Animate.css 中定义的一个 CSS 类,它可以让元素使用 Animate.css 中的动画。而 "bounce" 则是 Animate.css 中的一个动画类,它可以让元素跳动。 你也可以将动画绑定到 Vue.js 的过渡效果中,比如在元素显示和隐藏时使用不同的动画。下面是一个例子: ```html <transition enter-active-class="animated bounceInLeft" leave-active-class="animated bounceOutRight"> <div v-if="show"> Hello World! </div> </transition> ``` 这里我们使用了 Vue.js 的过渡效果,并将 "enter-active-class" 和 "leave-active-class" 属性设置为 Animate.css 中的 "bounceInLeft" 和 "bounceOutRight" 动画类。当元素显示时,它会从左侧弹出;当元素隐藏时,它会向右侧弹出。 以上就是使用 Vue-Animate-CSS 的基本方法。你可以在其官网上查看更多使用方法和示例:https://github.com/asika32764/vue-animate-css

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值