2019-07-04 10:59:40 +08:00
|
|
|
import * as throttleUtil from '@/utils/throttle';
|
2019-07-02 16:29:52 +08:00
|
|
|
|
|
|
|
export default {
|
2020-04-28 14:49:42 +08:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
_clientWidth: 0,
|
|
|
|
_clientHeight: 0
|
|
|
|
};
|
|
|
|
},
|
|
|
|
beforeMount() {
|
|
|
|
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
this._resizeHandler();
|
|
|
|
// 调用节流函数限制执行频率
|
|
|
|
var fn = throttleUtil.createOrUpdate(
|
|
|
|
this,
|
|
|
|
'_resizeHandler',
|
|
|
|
300,
|
|
|
|
'debounce'
|
|
|
|
);
|
|
|
|
window.addEventListener('resize', fn);
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
_resizeHandler() {
|
|
|
|
this._clientWidth = document.documentElement.clientWidth;
|
|
|
|
this._clientHeight = document.documentElement.clientHeight;
|
|
|
|
if (this.resizeHandler) {
|
|
|
|
this.resizeHandler();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
beforeDestroy() {
|
|
|
|
window.removeEventListener('resize', this._resizeHandler);
|
|
|
|
}
|
2019-07-04 10:59:40 +08:00
|
|
|
};
|