I have a image slide component which has resize event
imageSliderComponent.vue
methods: {
resize: function () {
console.log(this.$el)
// Handle window resize
// Code
}
}
mounted () {
window.onresize = this.resize
}
And in the parent component i am using this image slider in multiple places, some thing like this
App.vue
<image-slider :data="data1" /> // Slider 1
<image-slider :data="data2" /> // Slider 2
So when i try to resize the window, window.resize event is working only for the last occurred component(i.e., Slider 2). For the first component(Slider 1) resize method is not working.
Is there any way to handle resize independently for reusable component? please suggest if there is any other different implementation.