Shang Silicon Valley's Vue Journey 13-02-La transición y la animación en Vue 02

Ejemplo de código

<style>
	.bounce-enter-active {
    
    
	  animation: bounce-in .5s;
	}
	.bounce-leave-active {
    
    
		/* reverse:反着来 */
	  animation: bounce-in .5s reverse;
	}
	@keyframes bounce-in {
    
    
	  /* 时间的位置 */
	  0% {
    
    
	    /* scale: 字体到特定时间时所呈现的规模 */
		transform: scale(0);
	  }
	  50% {
    
    
	    transform: scale(1.5);
	  }
	  100% {
    
    
	    transform: scale(1);
	  }
	}
</style>

 

<div id="example-2">
  <button @click="show = !show">Toggle show</button><br>
  <transition name="bounce">
	  <!-- 当文本内容较少时,可以加上style="display: inline-block;",效果会更好一点 -->
   	 <p v-if="show" style="background: red; display: inline-block;">Lorem ipsum</p>
  </transition>
</div>

 

<script src="../js/vue.js" type="text/javascript" charset="utf-8"></script>
<script>
	new Vue({
    
    
	  el: '#example-2',
	  data: {
    
    
	    show: true
	  }
	})
</script>

  En el efecto de este código, cuando el contenido del texto es menor, puede agregar style = "display: inline-block;", el efecto será mejor.
  Este código proviene del sitio web oficial de vue.js-Transition and Animation

Supongo que te gusta

Origin blog.csdn.net/A_Bow/article/details/113747165
Recomendado
Clasificación