收藏
回答

我写的这个vue的动画效果,总出不来效果,怎么回事?

我写的这个vue的动画效果,总出不来效果,怎么回事?


<!DOCTYPE html>
<html lang="en">
 
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <title>动画</title>
    <style>
        .content {
            width: 200px;
            height: 200px;
            border: 1px solid #ff0000;
        }
         
        .xxx-enter-active,
        .xxx-leave-active {
            transition: background 5 ease;
        }
         
        .xxx-enter {
            background: red;
        }
         
        .xxx-enter-to {
            background: blue;
        }
         
        .xxx-leave {
            background: red;
        }
         
        .xxx-leave-to {
            background: orange;
        }
    </style>
</head>
 
<body>
    <div id="root">
        <button @click="toggle">toggle</button>
        <transition name="xxx">
            <div class="content" v-show="isShow">{{content}}</div>
        </transition>
 
    </div>
    <script>
        new Vue({
            el: "#root",
            data: {
                content: "我是内容",
                isShow: true
            },
            methods: {
                toggle: function() {
                    this.isShow = !this.isShow
                }
            }
        })
    </script>
</body>
 
</html>


回答关注问题邀请回答
收藏

3 个回答

  • 谢谢惠顾.
    谢谢惠顾.
    2019-11-29
    <template>
      <div id="demo">
        <div id="root">
          <button @click="handleClick">切换</button>
          <transition name="fade">
            <div class="content" v-show="show">hello world</div>
          </transition>
        </div>
      </div>
    </template>
    <script>
    export default {
      data() {
        return {
          show: true
        };
      },
      methods: {
        handleClick: function() {
          this.show = !this.show;
        }
      }
    };
    </script>
     
    <style lang="less" scoped>
    .content {
      width: 200px;
      height: 200px;
      border: 1px solid #ff0000;
    }
    .fade-enter,
    .fade-enter-active {
      transition: background 3s;
      background: orange;
    }
    .fade-leave-to,
    .fade-leave-active {
      transition: background 3s;
      background: pink;
    }
    </style>


    2019-11-29
    有用
    回复
  • 小满
    小满
    2019-11-29

    亲,vue专区提问。还有这不叫动画

    2019-11-29
    有用
    回复 1
    • 谢谢惠顾.
      谢谢惠顾.
      2019-11-29
      也算是vue的动画吧
      2019-11-29
      回复
  • 青团社
    青团社
    2019-11-29

    哈哈?是点击收起和展开么

    2019-11-29
    有用
    回复 2
    • 立志大灰郎
      立志大灰郎
      2019-11-29
      是背景色变换
      2019-11-29
      回复
    • 小满
      小满
      2019-11-29
      点击关闭隐藏,背景色AI智能变换
      2019-11-29
      回复
登录 后发表内容
问题标签