Commit 373dfb3cad8fcffcea3c71b6b67f9575f1e1f511
1 parent
8f4e2cf0
removed observer
Showing
2 changed files
with
11 additions
and
19 deletions
Show diff stats
src/components/carousel/carousel-item.vue
@@ -23,9 +23,10 @@ | @@ -23,9 +23,10 @@ | ||
23 | } | 23 | } |
24 | }, | 24 | }, |
25 | compiled () { | 25 | compiled () { |
26 | - // this.$parent.slotChange(); | ||
27 | - // this.$parent.updateSlides(true, true); | ||
28 | - // this.$parent.updatePos(); | 26 | + this.$parent.slotChange(); |
27 | + }, | ||
28 | + beforeDestroy () { | ||
29 | + this.$parent.slotChange(); | ||
29 | } | 30 | } |
30 | }; | 31 | }; |
31 | </script> | 32 | </script> |
src/components/carousel/carousel.vue
@@ -137,8 +137,13 @@ | @@ -137,8 +137,13 @@ | ||
137 | }, | 137 | }, |
138 | // use when slot changed | 138 | // use when slot changed |
139 | slotChange () { | 139 | slotChange () { |
140 | - this.slides = []; | ||
141 | - this.slideInstances = []; | 140 | + this.$nextTick(() => { |
141 | + this.slides = []; | ||
142 | + this.slideInstances = []; | ||
143 | + | ||
144 | + this.updateSlides(true, true); | ||
145 | + this.updatePos(); | ||
146 | + }); | ||
142 | }, | 147 | }, |
143 | handleResize () { | 148 | handleResize () { |
144 | this.$nextTick(() => { | 149 | this.$nextTick(() => { |
@@ -167,20 +172,6 @@ | @@ -167,20 +172,6 @@ | ||
167 | }, | 172 | }, |
168 | compiled () { | 173 | compiled () { |
169 | this.updateSlides(true); | 174 | this.updateSlides(true); |
170 | - | ||
171 | - // watch slot changed | ||
172 | - if (MutationObserver) { | ||
173 | - this.observer = new MutationObserver(() => { | ||
174 | - this.slotChange(); | ||
175 | - this.updateSlides(true, true); | ||
176 | - }); | ||
177 | - | ||
178 | - this.observer.observe(this.$els.slides, { | ||
179 | - childList: true, | ||
180 | - characterData: true, | ||
181 | - subtree: true | ||
182 | - }); | ||
183 | - } | ||
184 | }, | 175 | }, |
185 | watch: { | 176 | watch: { |
186 | autoplay () { | 177 | autoplay () { |