vue同个按钮控制展开和折叠同个事件操作

(编辑:jimmy 日期: 2024/9/21 浏览:2)

我就废话不多说了,大家还是直接看代码吧~

<el-button :icon="!moreshow" @click="getmoreshow">{{!moreshow"htmlcode">

data() {
  return {
  moreshow:false,
  count:1,
  }
}
mounted() {
  this.getmoreshow()//避免点击两次才生效
},
methods: {
  getmoreshow(){
  if(this.count%2==0){
   this.moreshow=true
  }else{
   this.moreshow=false
  }
  this.count++
  },
}

补充知识:vue 可折叠面板的工作区组件

这个组件中使用了elementui的两个图标

组件Js:

Vue.component('work-container', {
  props: ['height'],
  data: function () {
    return {
      isCollapse: false
    }
  },
  computed: {
    topbarcssobj: function () {
      var obj = { padding: '3px' };
      if (this.isCollapse) {
        obj.display = 'none';
      }
      else {
        obj.display = 'block';
        if (this.height) {
          obj.height = this.height + 'px';
        } else {
          obj.height = '40px';
        }
      }
      return obj;
    },
    btniconcssobj: function () {
      return this.isCollapse "topbarcssobj">          <slot name="tbar"></slot>          </el-header>          <el-main>          <div style="margin:3px;">            <div style="float:left;margin-right:10px;cursor:pointer;color: #d3dce6;display:none;" v-on:click="togglebar">              <i v-bind:class="btniconcssobj">{{strview}}查询条件</i>            </div>            <div>            <slot name="btn"></slot>            </div>          </div>          <div>            <slot name="work"></slot>          </div>          </el-main>         </el-container>'
});

调用:

<script src="/UploadFiles/2021-04-02/workcontainer.js">

以上这篇vue同个按钮控制展开和折叠同个事件操作就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。

一句话新闻

微软与英特尔等合作伙伴联合定义“AI PC”:键盘需配有Copilot物理按键
几个月来,英特尔、微软、AMD和其它厂商都在共同推动“AI PC”的想法,朝着更多的AI功能迈进。在近日,英特尔在台北举行的开发者活动中,也宣布了关于AI PC加速计划、新的PC开发者计划和独立硬件供应商计划。
在此次发布会上,英特尔还发布了全新的全新的酷睿Ultra Meteor Lake NUC开发套件,以及联合微软等合作伙伴联合定义“AI PC”的定义标准。