m2-ui
Version:
The package is provided web components and utilities based on vue and element-ui.
46 lines (41 loc) • 1.19 kB
JavaScript
;
exports.__esModule = true;
var _m2Core = require('m2-core');
exports.default = {
data: function data() {
return {
contentHeight: '100%',
clientHeight: '1000px'
};
},
computed: {
contentStyle: function contentStyle() {
return this.contentHeight > 0 ? { height: this.contentHeight + 'px' } : { height: this.contentHeight };
}
},
mounted: function mounted() {
var _this = this;
this.$nextTick(function () {
return _this.initContentHeight();
});
},
methods: {
initContentHeight: function initContentHeight() {
this.resizeWindow();
window.addEventListener('resize', this.resizeWindow);
},
resizeWindow: function resizeWindow() {
// 获取浏览器可视区域高度
var docEl = document.documentElement;
this.clientHeight = '' + docEl.clientHeight;
if (_m2Core.DataType.isFunction(this.calculateHeight)) {
this.contentHeight = this.calculateHeight(this.clientHeight);
} else {
this.contentHeight = this.clientHeight;
}
}
},
destroyed: function destroyed() {
window.removeEventListener('resize', this.resizeWindow);
}
};