效果如圖,移入移出控制摺疊,點擊按鈕後移入移出不可控制摺疊。javascript
功能是很簡單的功能,不過昨天這塊仍是弄了小一個小時,因此記錄下來。java
templatemarkdown
<el-container> <el-header> <button @click="collapseStatus"> <i class="el-icon-d-arrow-right"></i> </button> </el-header> <el-container> <el-aside width="auto" @mouseenter.native="collapseOpen" @mouseleave.native="collapseClose"> <el-menu :collapse="isCollapse"> <el-menu-item index="1"> <i class="el-icon-menu"></i> <span slot="title">測試</span> </el-menu-item> </el-menu> </el-aside> <el-main> </el-main> </el-container> </el-container>
scriptdom
data() { return { collapseBtnClick: false, isCollapse: true, } } methods: { collapseStatus() { this.collapseBtnClick = this.isCollapse; this.isCollapse = !this.isCollapse; }, collapseOpen() { if (this.collapseBtnClick) return; this.isCollapse = false; } } collapseClose() { if (this.collapseBtnClick) return; this.isCollapse = true; } }
這裏markdown的代碼不能自動排版,雲筆記的就會,必定是我寫的方式不對ide