vue 监听 页面宽度变化

vue yekong 450℃

可以获取到当前网页宽度和当前网页高度

 mounted() {
    window.addEventListener('resize', this.getHeight)
  },
  methods: {
    getHeight(e) {
      console.log(e.target.innerHeight) //当前网页高度
      console.log(e.target.innerWidth)  //当前网页宽度
    },
  },
  filters: {},
  watch: {},
  beforeRouteLeave(to, from, next) {
    // 离开页面时取消监听
    window.removeEventListener('resize', this.getHeight)
    next()
  },
喜欢 (1)