Commit ad74efbc83bcc7f2e7777e5e282b896356fad328
1 parent
2ec84333
fixed the bug about v-modle
Showing
1 changed file
with
9 additions
and
5 deletions
Show diff stats
src/components/layout/sider.vue
@@ -115,8 +115,8 @@ | @@ -115,8 +115,8 @@ | ||
115 | methods: { | 115 | methods: { |
116 | toggleCollapse () { | 116 | toggleCollapse () { |
117 | this.isCollapsed = this.collapsible ? !this.isCollapsed : false; | 117 | this.isCollapsed = this.collapsible ? !this.isCollapsed : false; |
118 | - this.$emit('input', !this.isCollapsed); | ||
119 | - this.$emit('on-collapse', !this.isCollapsed); | 118 | + this.$emit('input', this.isCollapsed); |
119 | + this.$emit('on-collapse', this.isCollapsed); | ||
120 | }, | 120 | }, |
121 | matchMedia () { | 121 | matchMedia () { |
122 | let matchMedia; | 122 | let matchMedia; |
@@ -137,12 +137,16 @@ | @@ -137,12 +137,16 @@ | ||
137 | } | 137 | } |
138 | }, | 138 | }, |
139 | mounted () { | 139 | mounted () { |
140 | - on(window, 'resize', this.onWindowResize); | ||
141 | - this.matchMedia(); | ||
142 | - this.$emit('input', this.defaultCollapsed); | ||
143 | if (this.defaultCollapsed) { | 140 | if (this.defaultCollapsed) { |
144 | this.isCollapsed = true; | 141 | this.isCollapsed = true; |
142 | + this.$emit('input', this.defaultCollapsed); | ||
143 | + } else { | ||
144 | + if (this.value !== undefined) { | ||
145 | + this.isCollapsed = this.value; | ||
146 | + } | ||
145 | } | 147 | } |
148 | + on(window, 'resize', this.onWindowResize); | ||
149 | + this.matchMedia(); | ||
146 | }, | 150 | }, |
147 | destroyed () { | 151 | destroyed () { |
148 | off(window, 'resize', this.onWindowResize); | 152 | off(window, 'resize', this.onWindowResize); |