vue高度自适应与背景颜色+组件

import myhea from '@/components/hea.vue'
export default {
name: 'App',
props: ["titlevlu", "lefttext"],
components: {
myhea
},
data() {
return {
myactive: 0,
conheight: {
height: ''
}
};
},
mounted() {
document.querySelector('body').setAttribute('style', 'background-color:#F4F5F7')
},
beforeDestroy() {
document.querySelector('body').removeAttribute('style')
},
methods: {
getHeight() {
this.conheight.height = window.innerHeight - 170 + 'px';
},
created() {
window.addEventListener('resize', this.getHeight);
this.getHeight()
}
},
}

  

<div :style="conheight">

  

posted @ 2020-09-10 17:33  文采呱呱  阅读(682)  评论(0编辑  收藏  举报