Vue.js get screen height


We can use screen height property to get the total height of the screen. Here in this tutorial, we are going to explain how you can use screen height object to get the height of the screen. You can also use our online editor to edit and run the code online.


Vue.js get screen height Example

You can get screen height in vuejs simply as below-

Example:

<div id="app">
	<p>{{result}}</p>
	<button @click="myFunction()">Click Me</button>
</div>
<script>
 new Vue({
el: '#app',
  
  data: { 
	  result:""
  },
  
   methods:{
    myFunction: function () {	
		this.result = screen.height+"px";
    }
   }

});
</script>      

Try it »

Output of above example-

vue.js get screen height

Advertisements

Add Comment

📖 Read More