使用VUE開發後臺項目,後臺項目須要進行後臺根據瀏覽器窗口進行變化,須要使用vue來監聽瀏覽器的窗口變化。vue
<template> <div class="content" :style="height"></div> </template> <script> export default { name: 'App', data () { return { height:'', } }, components:{}, methods:{ getHeight(){ this.height = window.innerHeight - 70 + 'px'; } }, created(){ window.addEventListener('resize', this.getHeight); this.getHeight() }, destroyed(){ window.removeEventListener('resize', this.getHeight) } } </script>