Commit 76db49cd1642b64c9d5a749addaf17b86e91c8d9
1 parent
1c26d05c
replay class attr which using inline styles with computed props
Showing
1 changed file
with
16 additions
and
2 deletions
Show diff stats
src/components/layout/sider.vue
1 | 1 | <template> |
2 | 2 | <div |
3 | 3 | :class="wrapClasses" |
4 | - :style="{width: siderWidth + 'px', minWidth: siderWidth + 'px', maxWidth: siderWidth + 'px', flex: '0 0 ' + siderWidth + 'px'}"> | |
4 | + :style="wrapStyles"> | |
5 | 5 | <span v-show="showZeroTrigger" @click="toggleCollapse" :class="zeroWidthTriggerClasses"> |
6 | 6 | <i class="ivu-icon ivu-icon-navicon-round"></i> |
7 | 7 | </span> |
8 | - <div :class="`${prefixCls}-children`"> | |
8 | + <div :class="childClasses"> | |
9 | 9 | <slot></slot> |
10 | 10 | </div> |
11 | 11 | <div v-show="showBottomTrigger" :class="triggerClasses" @click="toggleCollapse" :style="{width: siderWidth + 'px'}"> |
... | ... | @@ -72,12 +72,23 @@ |
72 | 72 | this.isCollapsed ? `${prefixCls}-collapsed` : '' |
73 | 73 | ]; |
74 | 74 | }, |
75 | + wrapStyles () { | |
76 | + return { | |
77 | + width: `${this.siderWidth}px`, | |
78 | + minWidth: `${this.siderWidth}px`, | |
79 | + maxWidth: `${this.siderWidth}px`, | |
80 | + flex: `0 0 ${this.siderWidth}px` | |
81 | + }; | |
82 | + }, | |
75 | 83 | triggerClasses () { |
76 | 84 | return [ |
77 | 85 | `${prefixCls}-trigger`, |
78 | 86 | this.isCollapsed ? `${prefixCls}-trigger-collapsed` : '', |
79 | 87 | ]; |
80 | 88 | }, |
89 | + childClasses () { | |
90 | + return `${this.prefixCls}-children`; | |
91 | + }, | |
81 | 92 | zeroWidthTriggerClasses () { |
82 | 93 | return [ |
83 | 94 | `${prefixCls}-zero-width-trigger`, |
... | ... | @@ -129,6 +140,9 @@ |
129 | 140 | on(window, 'resize', this.onWindowResize); |
130 | 141 | this.matchMedia(); |
131 | 142 | this.$emit('input', this.defaultCollapsed); |
143 | + if (this.defaultCollapsed) { | |
144 | + this.isCollapsed = true; | |
145 | + } | |
132 | 146 | }, |
133 | 147 | destroyed () { |
134 | 148 | off(window, 'resize', this.onWindowResize); | ... | ... |