vue emit composition api
// App.vue
<template>
<div id="app" style={{ width: widthPixel, height: heightPixel }}>
dynamic window size: {width}, {height}
</div>
</template>
<script>
import { watch } from '@vue/composition-api'
export default {
setup(props, { emit }) {
const { width, height, widthPixel, heightPixel } = useWindowSize()
watch(() => {
emit('window-width-changed', width)
})
return { width, height, widthPixel, heightPixel }
}
}
</script>