<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <div id="app">
        <input type="button" value="隐藏/显示" @click="flag = !flag">
        <transition name="fade">
            <div v-if="flag">不见不散</div>
        </transition>
    </div>

    <script src="../js/vue.js"></script>

    <script>
        const vm = new Vue({
            el:'#app',
            data : {
                flag:false
            },
            methods : {

            }
        })
    </script>

    <style>
        .fade-enter,
        .fade-leave-to {
            opacity: 0;
            transform: translateX(100px);
        }

      .fade-enter-active,
      .fade-leave-active{
          transition: all 0.2s ease;
          position:absolute;
      }
    </style>
</body>
</html>