| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | export default {
mounted () {
this.$bindResize()
},
methods: {
$bindResize () {
this._handleResize = (e) => {
if (this.onResize) this.onResize()
}
window.addEventListener('resize', this._handleResize)
},
$unBindResize () {
if (this._handleResize) window.removeEventListener('resize', this._handleResize)
}
},
beforeDestroy () {
this.$unBindResize()
}
}
|