//defaultHeight是绑定的属性
<el-main :style="defaultHeight">
<router-view />
</el-main>
//注意:这里的defaultHeight必须是对象,不懂的可以去官网看下api
data() {
return {
defaultHeight: {
height: ""
}
};
},
methods: {
//定义方法,获取高度减去头尾
getHeight() {
this.defaultHeight.height = window.innerHeight - 90 + "px";
}
},
created() {
//页面创建时执行一次getHeight进行赋值,顺道绑定resize事件
window.addEventListener("resize", this.getHeight);
this.getHeight();
}
原地址:https://www.cnblogs.com/jwen1994/p/13571720.html
标签:vue,elementUI,getHeight,height,适应,window,defaultHeight,resize From: https://www.cnblogs.com/lt0222/p/17037020.html