diff --git a/examples/routers/layout.vue b/examples/routers/layout.vue index 2369f9bf..74f959ed 100644 --- a/examples/routers/layout.vue +++ b/examples/routers/layout.vue @@ -4,6 +4,7 @@ diff --git a/src/components/layout/sider.vue b/src/components/layout/sider.vue index 44657dc8..bd794f68 100644 --- a/src/components/layout/sider.vue +++ b/src/components/layout/sider.vue @@ -8,7 +8,7 @@
-
+
@@ -44,6 +44,10 @@ return oneOf(val, ['xs', 'sm', 'md', 'lg', 'xl']); } }, + collapsible: { + type: Boolean, + default: false + }, defaultCollapsed: { type: Boolean, default: false @@ -88,15 +92,18 @@ ]; }, siderWidth () { - return this.isCollapsed ? (this.mediaMatched ? 0 : parseInt(this.collapsedWidth)) : parseInt(this.width); + return this.collapsible ? (this.isCollapsed ? (this.mediaMatched ? 0 : parseInt(this.collapsedWidth)) : parseInt(this.width)) : this.width; }, showZeroTrigger () { - return this.mediaMatched && !this.hideTrigger || (parseInt(this.collapsedWidth) === 0) && this.isCollapsed && !this.hideTrigger; + return this.collapsible ? (this.mediaMatched && !this.hideTrigger || (parseInt(this.collapsedWidth) === 0) && this.isCollapsed && !this.hideTrigger) : false; + }, + showBottomTrigger () { + return this.collapsible ? !this.mediaMatched && !this.hideTrigger : false; } }, methods: { toggleCollapse () { - this.isCollapsed = !this.isCollapsed; + this.isCollapsed = this.collapsible ? !this.isCollapsed : false; this.$emit('input', !this.isCollapsed); this.$emit('on-collapse', !this.isCollapsed); }, @@ -109,7 +116,7 @@ this.mediaMatched = matchMedia(`(max-width: ${dimensionMap[this.breakpoint]})`).matches; if (this.mediaMatched !== mediaMatched) { - this.isCollapsed = this.mediaMatched; + this.isCollapsed = this.collapsible ? this.mediaMatched : false; this.$emit('input', this.mediaMatched); this.$emit('on-collapse', this.mediaMatched); }