vue elementui簡易側拉欄的使用小結
更新時間:2024年06月27日 10:41:37 作者:極端~
這篇文章主要介紹了vue elementui簡易側拉欄的使用,增加了側拉欄,目的是可以選擇多條數據展示數據,本文通過示例代碼給大家介紹的非常詳細,感興趣的朋友跟隨小編一起看看吧
如圖所示,增加了側拉欄,目的是可以選擇多條數據展示數據


組件: celadon.vue
<template>
<div class="LayoutMain">
<el-aside :width="sidebarIsCollapse ? '180px' : '0px'" class="aside-wrap">
<template>
<div
:class="[
'aside-wrap-header',
{ 'aside-wrap-header--hide': sidebarIsCollapse },
]"
@click="toggleCollapse"
></div>
<div class="aside-wrap-slot">
<slot class="btnSlot" name="asideWrapSlot" />
</div>
</template>
</el-aside>
<div
class="layout-main-btn"
:class="['left', { hide: !sidebarIsCollapse }]"
@click="toggleCollapse"
>
<template v-if="sidebarIsCollapse">
<i class="el-icon-arrow-left" />
</template>
<template v-else>
<i class="el-icon-arrow-right" />
</template>
</div>
</div>
</template>
<script>
export default {
name: "LayoutMain",
components: {},
props: {
sidebarIsCollapse: {
type: Boolean,
default: false,
},
menuName: {
type: String,
default: "",
},
},
data() {
return {};
},
methods: {
toggleCollapse() {
this.$emit("toggleCollapse");
},
},
};
</script>
<style lang="scss" scoped>
.LayoutMain {
background: transparent;
height: 100%;
width: 100%;
display: flex;
::v-deep .el-main {
padding: 16px !important;
}
.aside-wrap {
height: 100%;
background: rgba(67, 133, 219, 0.301);
transition: width 0.4s;
.aside-wrap-header {
display: flex;
// height: 48px;
align-items: center;
padding: 0 16px;
font-size: 14px;
font-family: PingFangSC-Semibold, PingFang SC;
font-weight: 600;
color: #333333;
cursor: pointer;
&::v-deep .el-menu::-webkit-scrollbar {
width: 0 !important;
-ms-overflow-style: scroll;
overflow: scroll;
}
}
}
.layout-main-btn {
position: absolute;
top: 40px;
z-index: 999;
height: 56px;
line-height: 54px;
text-align: center;
width: 14px;
border-radius: 10px;
border: 0.5px solid #ccc;
background: rgb(27, 118, 238);
cursor: pointer;
i {
color: #e4dada;
font-size: 14px;
}
}
.left {
left: 180px;
transition: left 0.4s;
}
.hide {
left: -5px;
transition: left 0.4s;
}
}
</style>在頁面使用
<!--數據分析側拉欄-->
<div style="z-index:999; position: absolute;width: 180px;height: 300px;"
>
<celadon
style="
margin-top: 40px;
height: 100%;
width: 100%;
overflow: scroll;
"
:sidebar-is-collapse="sidebarIsCollapse"
@toggleCollapse="toggleCollapse"
>
<div class="select-items" slot="asideWrapSlot">
<div
class="selset-item"
v-for="(item, index) in items"
:key="index"
>
<input
type="checkbox"
:id="'checkbox-' + index"
v-model="selectedItems"
:value="item"
@click="selectCheckBox"
/>
<label :for="'checkbox-' + index">{{ item.name }}</label>
</div>
<el-button style="margin: 20px 30px" size="small" type="primary"
>選擇</el-button
>
</div>
</celadon>
</div>
<!--data-->
items: [
{ name: "1號設備", value: "12" },
{ name: "2號設備", value: "13" },
{ name: "3號設備", value: "4" },
{ name: "3號設備", value: "2" },
{ name: "3號設備", value: "3" },
{ name: "3號設備", value: "1" },
{ name: "3號設備", value: "11" },
{ name: "3號設備", value: "14" },
{ name: "3號設備", value: "15" },
{ name: "3號設備", value: "16" },
{ name: "3號設備", value: "17" },
{ name: "3號設備", value: "33" },
{ name: "3號設備", value: "22" },
{ name: "3號設備", value: "55" },
{ name: "3號設備", value: "66" },
{ name: "3號設備", value: "31" },
{ name: "3號設備", value: "56" },
{ name: "3號設備", value: "45" },
],
<!--methods-->
selectCheckBox(value){
console.log(value)
},
toggleCollapse() {
this.sidebarIsCollapse = !this.sidebarIsCollapse;
},到此這篇關于vue elementui簡易側拉欄的使用的文章就介紹到這了,更多相關vue elementui側拉欄內容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
相關文章
關于Vue開發(fā)中v-if和v-show的聯合使用步驟
本文探討了在Vue.js項目中如何有效利用v-if和v-show指令來實現多步驟表單導航,確保用戶操作數據能在前后步驟間保持不變,通過具體案例分析了這兩種指令的特點及結合使用的最佳實踐,感興趣的朋友跟隨小編一起看看吧2025-09-09
Vue3造輪子之Typescript配置highlight過程
這篇文章主要介紹了Vue3造輪子之Typescript配置highlight過程,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教2024-07-07

