elementUI内置过渡(折叠)

Posted on 2019-10-01 12:14  猫头唔食鱼  阅读(6150)  评论(1编辑  收藏  举报

elementUI内置过渡动画(折叠),使用<el-collapse-transition>标签包裹要折叠的元素即可

例子:

<template>
  <div>
    <div class="ctn">
      <!-- 使用el-collapse-transition标签包裹着需要折叠的元素 -->
      <el-collapse-transition>
        <div class="box" v-show="show">el-collapse-transition</div>
      </el-collapse-transition>
    </div>
    <el-button type="primary" @click="test()">折叠</el-button>
  </div>
</template>
<script>
export default {
  name: "HelloWorld",
  data() {
    return {
      show: true
    };
  },
  methods: {
    test() {
      this.show = !this.show;
    }
  }
};
</script>
<style lang="css" scoped>
.ctn {
  width: 500px;
  height: 300px;
}

.box {
  display: inline-block;
  width: 200px;
  height: 200px;
  line-height: 200px;
  text-align: center;
  color: #fff;
  background-color: greenyellow;
  margin-right: 20px;
}
</style>