vue.js method to dynamically set element height: [<div :style="{width: divWidth, height: divHeight}"></div>data() {//Storing data} 】.
The operating environment of this article: windows10 system, vue.js 2.9, thinkpad t480 computer.
Without further ado, let’s go directly to the code:
vue code:
<div :style="{width: divWidth, height: divHeight}"></div>
data data:
data() { //这里存放数据 return { divHeight:0, divWidth:0 } },
created method assignment
created(){ let divWidth = document.body.clientWidth+"px"; let divHeight = document.body.clientHeight-130+"px"; this.divWidth = divWidth this.divHeight = divHeight },
Recommended learning: php training
The above is the detailed content of How to dynamically set element height in vue.js. For more information, please follow other related articles on the PHP Chinese website!