Sobre o layout dinâmico de altura do terminal móvel
Quando a página não usa o teclado virtual, você pode usar calc () para calcular a altura restante
< div>
< div class = "header" > < / div>
< div class = "content" > < / div>
< div class = "footer" > < / div>
< / div>
< style>
. header {
height: 10 rem;
}
. content {
height: calc ( ~ "100vh - 10rem - 40px" ) ;
}
. footer {
height: 40 px;
}
< / style>
Quando a página usa o teclado virtual, se você ainda usa calc () para calcular a altura, a altura do conteúdo será comprimida pelo teclado virtual pop-up e você precisa usar px para definir a altura para resolver a situação em que o a altura do conteúdo está comprimida
< div>
< div class = "header" > < / div>
< div : style= "{height: content}" >
< input type= "text" / >
< / div>
< div class = "footer" > < / div>
< / div>
< script>
data ( ) {
return {
content: "" ,
}
} ,
mounted ( ) {
let header = "10" ;
let footer = document. getElementsByClassName ( "footer" ) [ 0 ] ;
footer = parseFloat ( window. getComputedStyle ( footer) . height) ;
this . content = this . getHeight ( header, footer) ;
} ,
methods: {
getHeight ( remHeight = 0 , pxHeight = 0 ) {
let gmax = parseFloat ( document. body. style. fontSize) ;
let otherHeight = ( remHeight * gmax) + pxHeight;
return ` ${
document. documentElement. clientHeight - otherHeight} px`
}
}
< / script>
< style>
. header {
height: 10 rem;
}
. footer {
height: 40 px;
}
< / style>