栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > Web开发 > JavaScript

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

JavaScript 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

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

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

{{!moreshow?更多:隐藏}}

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 ? 'el-icon-caret-bottom' : 'el-icon-caret-top';
    },
    strview: function () {
      return this.isCollapse ? '显示' : '隐藏';
    }
  },
  methods: {
    togglebar: function () {
      this.isCollapse = !this.isCollapse;
    }
  },
  template: '
   
   
   
   
   
     
{{strview}}查询条件
     
     
     
     
   
   
     
   
   
  '
});

调用:



 
    
    
  

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

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/69373.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号