Article From:https://segmentfault.com/q/1010000011358599
Question:

I know it should be written in mounted.

$('body').css({'height':$(window).height()});

But how should the original be realized?

Answer 0:

Do you all ignore a CSS attribute?
Direct setting:

body{
  height:100vh;
}

As for vh:100vh, it is equal to the height of the current window, and the same is VW.

Answer 1:

This has nothing to do with the Vue framework. It’s CSS’s problem.

<html>
    <body>
        <div class="app"></div>
    </body>
</html>
<style>
    html,body {
        width: 100%;
        height: 100%;
    }
</style>

Answer 2:

cssLi, HTML, body{height:100%}
jsWords

 var doc = document.documentElement;
    document.body.style.height =  doc.scrollHeight+'px';

Answer 3:

jsGet the window size:
document.documentElement.clientWidth ==> Visible area width
The same height.
Then you call it in created or mounted method.

Similar Posts:

Leave a Reply

Your email address will not be published. Required fields are marked *