vue同個(gè)按鈕控制展開和折疊同個(gè)事件操作
我就廢話不多說了,大家還是直接看代碼吧~
<el-button :icon="!moreshow?'el-icon-arrow-down':'el-icon-arrow-up'" @click="getmoreshow">{{!moreshow?更多:隱藏}}</el-button>
data() { return { moreshow:false, count:1, } }
mounted() { this.getmoreshow()//避免點(diǎn)擊兩次才生效 }, methods: { getmoreshow(){ if(this.count%2==0){ this.moreshow=true }else{ this.moreshow=false } this.count++ }, }
補(bǔ)充知識:vue 可折疊面板的工作區(qū)組件
這個(gè)組件中使用了elementui的兩個(gè)圖標(biāo)
組件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: '<el-container>\ <el-header v-bind:style="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>' });
調(diào)用:
<script src="~/Scripts/vue/workcontainer.js"></script> <work-container v-bind:height="80"> <template v-slot:tbar> <spec-combo v-on:selectspec="setSpec"></spec-combo> <ban-input v-on:selectban="setBan"></ban-input> <grade-input v-on:selectban="setGrade"></grade-input> </template> <template v-slot:work> {{spec}} {{ban}} {{grade}} </template> </work-container>
以上這篇vue同個(gè)按鈕控制展開和折疊同個(gè)事件操作就是小編分享給大家的全部內(nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
vue中v-model如何綁定多循環(huán)表達(dá)式實(shí)戰(zhàn)案例
v-model綁定的變量無論是對象還是數(shù)組都是綁定的value值,下面這篇文章主要給大家介紹了關(guān)于vue中v-model如何綁定多循環(huán)表達(dá)式的相關(guān)資料,文中通過實(shí)例代碼介紹的非常詳細(xì),需要的朋友可以參考下2022-11-11使用Vant完成DatetimePicker 日期的選擇器操作
這篇文章主要介紹了使用Vant完成DatetimePicker 日期的選擇器操作,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-11-11webpack4+express+mongodb+vue實(shí)現(xiàn)增刪改查的示例
這篇文章主要介紹了webpack4+express+mongodb+vue 實(shí)現(xiàn)增刪改查的示例,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2018-11-11Vue3中使用qrcode庫實(shí)現(xiàn)二維碼生成
Vue3中實(shí)現(xiàn)二維碼生成需要使用第三方庫來處理生成二維碼的邏輯,常用的庫有?qrcode和?vue-qrcode,本文主要介紹了Vue3中使用qrcode庫實(shí)現(xiàn)二維碼生成,感興趣的可以了解一下2023-12-12vue3+ts項(xiàng)目之安裝eslint、prettier和sass的詳細(xì)過程
這篇文章主要介紹了vue3+ts項(xiàng)目02-安裝eslint、prettier和sass的詳細(xì)過程,在本文講解中需要注意執(zhí)行yarn format會自動(dòng)格式化css、js、html、json還有markdown代碼,需要的朋友可以參考下2023-10-10Vue.js實(shí)現(xiàn)雙向數(shù)據(jù)綁定方法(表單自動(dòng)賦值、表單自動(dòng)取值)
今天小編就為大家分享一篇Vue.js實(shí)現(xiàn)雙向數(shù)據(jù)綁定方法(表單自動(dòng)賦值、表單自動(dòng)取值),具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧2018-08-08