data() {//Storing data}]."/> data() {//Storing data}].">

Home  >  Article  >  Web Front-end  >  How to dynamically set element height in vue.js

How to dynamically set element height in vue.js

王林
王林Original
2021-10-09 17:42:215352browse

vue.js method to dynamically set element height: [d04fcf98c7c315a5d55dc020e0d4da5f16b28748ea4df4d9c2150843fecfba68data() {//Storing data} 】.

How to dynamically set element height in vue.js

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn