美文网首页
vue中appear的用法

vue中appear的用法

作者: 如果俞天阳会飞 | 来源:发表于2022-05-26 11:50 被阅读0次

来源: https://blog.csdn.net/wangxiaoxiaosen/article/details/77309552
关于appear的用户和enter的用法相似,它只是在第一次渲染的时候才会起作用

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>初始渲染的过渡</title>
      <script src="https://cdn.bootcdn.net/ajax/libs/vue/2.6.14/vue.common.dev.js"></script>

</head>
<style>

    .custom-appear-active{
        color: #2fe26d;
        background: #b6b6b6;
        transition: all 1s ease;
    }
    .custom-appear{
        font-size: 40px;
        color: #e069e2;
        background: #7798e2;
    }
    .custom-appear-to{
        color: #e29138;
        background: #1c8942;
    }
</style>
<body>
<div id="app">
    <transition
            appear
            appear-class="custom-appear"
            appear-to-class="custom-appear-to"
            appear-active-class="custom-appear-active"
    >
        <p>appear</p>
    </transition>

</div>
<script>
    new Vue({
        el: "#app"
    })
</script>
</body>
</html>

enter用法

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>初始渲染的过渡</title>
  <script src="https://cdn.bootcdn.net/ajax/libs/vue/2.6.14/vue.common.dev.js"></script>
</head>
<style>

  .custom-appear-active{
    color: #2fe26d;
    background: #b6b6b6;
    transition: all 1s ease;
  }
  .custom-appear{
    font-size: 40px;
    color: #e069e2;
    background: #7798e2;
  }
  .custom-appear-to{
    color: red;
    background: red;
  }
</style>
<body>
<div id="app">
  <div>
    <transition
      enter-class="custom-appear"
      enter-to-class="custom-appear-to"
      enter-active-class="custom-appear-active"
    >
      <p v-if="show">appear</p>
    </transition>
    <button @click="show=true">显示</button>
  </div>
</div>
<script type="module">
new Vue({
  el: "#app",
  data:{
    show: false,
  },
})
</script>
</body>
</html>

相关文章

网友评论

      本文标题:vue中appear的用法

      本文链接:https://www.haomeiwen.com/subject/owuuprtx.html