elementUI内置过渡(折叠)

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>

猜你喜欢

转载自www.cnblogs.com/luguankun/p/11615122.html