show1 true " />

飞道的博客

Vue动画库

376人阅读  评论(0)

vue动画库 velocity-animate

NPM

1:npm i velocity-animate

<template>
	<div>
		<transition @before-enter="beforeEnter" @enter="enter" @leave="leave" :css="false">
			<div  v-show="show1">
					show1 true false 执行 enter leave动画
			</div>
		</transition >
	</div>
</template>
<script>
export default {
	name: "APP",
  	data() {
  		return {
  			show1: true
  		}
  	},
  	methods: {
		//初始
	    beforeEnter: function(el) {
	      // console.log(el);
	      // alert("beforeEnter");
	      el.style.opacity = 0;
	      el.style.transformOrigin = "left";
	    },
	    enter: function(el, done) {
	      //进场动画
	      // alert("enter");
	      //  console.log(done);
	      let that = this;
	      Velocity(el, { opacity: 1 }, { duration: 500 });
	      // Velocity(el, {opacity:0}, {duration:1000, complete: function(){
	
	      // }});
	    },
	    leave: function(el, done) {
	      //离场动画
	      let that = this;
	      Velocity(el, { opacity: 0 }, { duration: 500 });
	    }
	}
}
</script>
[详情参考网址](https://www.npmjs.com/package/velocity-animate)

转载:https://blog.csdn.net/weixin_47981445/article/details/106773503
查看评论
* 以上用户言论只代表其个人观点,不代表本网站的观点或立场