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 | <template> | 1 | <template> |
2 | <div | 2 | <div |
3 | :class="wrapClasses" | 3 | :class="wrapClasses" |
4 | - :style="{width: siderWidth + 'px', minWidth: siderWidth + 'px', maxWidth: siderWidth + 'px', flex: '0 0 ' + siderWidth + 'px'}"> | 4 | + :style="wrapStyles"> |
5 | <span v-show="showZeroTrigger" @click="toggleCollapse" :class="zeroWidthTriggerClasses"> | 5 | <span v-show="showZeroTrigger" @click="toggleCollapse" :class="zeroWidthTriggerClasses"> |
6 | <i class="ivu-icon ivu-icon-navicon-round"></i> | 6 | <i class="ivu-icon ivu-icon-navicon-round"></i> |
7 | </span> | 7 | </span> |
8 | - <div :class="`${prefixCls}-children`"> | 8 | + <div :class="childClasses"> |
9 | <slot></slot> | 9 | <slot></slot> |
10 | </div> | 10 | </div> |
11 | <div v-show="showBottomTrigger" :class="triggerClasses" @click="toggleCollapse" :style="{width: siderWidth + 'px'}"> | 11 | <div v-show="showBottomTrigger" :class="triggerClasses" @click="toggleCollapse" :style="{width: siderWidth + 'px'}"> |
@@ -72,12 +72,23 @@ | @@ -72,12 +72,23 @@ | ||
72 | this.isCollapsed ? `${prefixCls}-collapsed` : '' | 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 | triggerClasses () { | 83 | triggerClasses () { |
76 | return [ | 84 | return [ |
77 | `${prefixCls}-trigger`, | 85 | `${prefixCls}-trigger`, |
78 | this.isCollapsed ? `${prefixCls}-trigger-collapsed` : '', | 86 | this.isCollapsed ? `${prefixCls}-trigger-collapsed` : '', |
79 | ]; | 87 | ]; |
80 | }, | 88 | }, |
89 | + childClasses () { | ||
90 | + return `${this.prefixCls}-children`; | ||
91 | + }, | ||
81 | zeroWidthTriggerClasses () { | 92 | zeroWidthTriggerClasses () { |
82 | return [ | 93 | return [ |
83 | `${prefixCls}-zero-width-trigger`, | 94 | `${prefixCls}-zero-width-trigger`, |
@@ -129,6 +140,9 @@ | @@ -129,6 +140,9 @@ | ||
129 | on(window, 'resize', this.onWindowResize); | 140 | on(window, 'resize', this.onWindowResize); |
130 | this.matchMedia(); | 141 | this.matchMedia(); |
131 | this.$emit('input', this.defaultCollapsed); | 142 | this.$emit('input', this.defaultCollapsed); |
143 | + if (this.defaultCollapsed) { | ||
144 | + this.isCollapsed = true; | ||
145 | + } | ||
132 | }, | 146 | }, |
133 | destroyed () { | 147 | destroyed () { |
134 | off(window, 'resize', this.onWindowResize); | 148 | off(window, 'resize', this.onWindowResize); |