Answers for "vue emit composition api"

0

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>
Posted by: Guest on May-07-2021

Browse Popular Code Answers by Language