<div class="leftBox" :style="{width:wrapBox.leftWidth+'px'}">
左侧部分
</div>
<div class="rightBox" :style="{width:wrapBox.rightWidth+'px'}">
右侧部分
</div>
data() {
return {
wrapBox: {
leftWidth: 250,
rightWidth: 500, //自适应
},
}
},
mounted() {
/* 右侧部分根据左侧宽度自适应 */
this.wrapBox.rightWidth = this.$refs.bottomBox.offsetWidth - this.wrapBox.leftWidth;
/* 窗口大小实时监听 */
this.screenWidth = document.body.clientWidth;
this.screenHeight = document.body.clientHeight;
window.onresize = () => {
return (() => {
this.screenWidth = document.body.clientWidth;
this.screenHeight = document.body.clientHeight;
this.wrapBox.rightWidth = this.screenWidth - this.wrapBox.leftWidth;
})()
}
},