Tutorialsplane

Vue.js Generate random number


To generate random number in vue.js we can use native JavaScript Math.random() function to generate random number. Here in this tutorial, we are going to explain how you can use Math.random() function in vuejs. You can also use our online editor to edit and run the code online.


Vue.js Generate random number JavaScript- VueJS Example

You can generate random number in vue.js simply as below-

Example:

<div id="app">	
	<p>Random Number = {{randomNumber}}</p>
	<button>Click Me</button>
</div>
   

Try it ยป

Output of above example-