vue 淡入淡出組件


vue.js中在不使用jQuery的情況下,如何實現淡入淡出的組件(用於顯示http請求成功或者失敗的消息提示)?
目前使用的是vue的transition動畫。

 <template>
  <div>
    <button v-on:click="Show">點擊動畫</button>
    <transition-group name="test">
      <h1 v-if="show" :key="1">hello</h1>
      <h2 v-if="show" :key="2">hello world!</h2>
    </transition-group>
  </div>
</template>

<script>


  export default {
    name: 'Test',
    data(){
      return { show:true}
    },
    methods:{
      Show(){
        this.show=!this.show;
      }
    }

  }
</script>

<style scoped>

  .test-enter,.test-leave-to{
    opacity: 0;
  }
  .test-enter-to,.test-leave{
    opacity: 1;
  }
  .test-enter-active,.test-leave-active{
    transition: all 2s;
  }
</style>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM