Skip to content

Instantly share code, notes, and snippets.

@ansidev
Created February 1, 2019 07:29
Show Gist options
  • Save ansidev/21643f57b5d9502517a076f6ccc89706 to your computer and use it in GitHub Desktop.
Save ansidev/21643f57b5d9502517a076f6ccc89706 to your computer and use it in GitHub Desktop.
Handle resize event in Nuxt JS
<script>
export default {
mounted: function () {
this.$nextTick(function () {
this.onResize();
})
window.addEventListener('resize', this.onResize)
},
methods: {
onResize() {
console.log('Resized')
}
}
}
</script>
@richardevcom
Copy link

richardevcom commented Apr 3, 2024

Vue 3

<script setup lang="ts">
	onMounted(() => window.addEventListener("resize", onResize, true))

	function onResize(): void {
		console.log('Resized')
	}
</script>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment