[demo](https://chengheai.github.io/Element-UI/docs/)

效果

vue点击收起部分隐藏
vue点击收起部分隐藏

代码

  <div>
    <div v-for="item in showdetailList" :key='item.message'>
      <h3>{{item.message}}</h3>
    </div>
  </div>
  <el-button type="success" v-if="items.length > 2" v-on:click="changeFoldState">
    <span>{{brandFold?'展开':'收起'}}</span>
  </el-button>
data(){
  return {
    brandFold: true,
      items: [{
        message: "Foo"
      }, {
        message: "Bar"
      }, {
        message: "alex"
      }]
  }
},
computed: {
    showetailList: {
      get: function () {
        if (this.brandFold) {
          if (this.items.length < 3) {
            return this.items
          }
          let newArr = []
          for (var i = 0; i < 2; i++) {
            let item = this.items[i]
            newArr.push(item)
          }
          return newArr
        }
        return this.items
      },
      set: function (val) {
        this.showdetailList = val
      }
    }
  },

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-05
  • 2022-12-23
  • 2022-12-23
  • 2021-11-13
  • 2021-11-23
  • 2021-11-02
猜你喜欢
  • 2021-11-13
  • 2021-12-28
  • 2021-11-13
  • 2021-11-25
  • 2021-11-13
  • 2022-12-23
  • 2021-09-15
相关资源
相似解决方案