If you are using multiple components with this solution, the accepted answer's resize handler function will update only the last component.
Then you should use this instead:
import { Component, Vue } from 'vue-property-decorator';
@Component
export class WidthWatcher extends Vue {
public windowWidth: number = window.innerWidth;
public mounted() {
window.addEventListener('resize', this.handleResize);
}
public handleResize() {
this.windowWidth = window.innerWidth;
}
public beforeDestroy() {
window.removeEventListener('resize', this.handleResize);
}
}
source: https://github.com/vuejs/vue/issues/1915#issuecomment-159334432