0๐
I mean its wrong tactic.
MDN writes:
The onresize property of the GlobalEventHandlers interface is an
EventHandler that processes resize events.
https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onresize
So when your second component has been mounted โ window.onresize
was rewritten
If you want to change something in a component when window be resized you can use "watch" methods https://v2.vuejs.org/v2/guide/computed.html
You need create a global variable like windowSize, when window was resized assign new size to windowSize, and in component watch windowsSize
Source:stackexchange.com