screen_rotation
Copied to Clipboard
<html> <head> <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> </head> <body> <h3>Vue Js Generate 6 digit OTP</h3> <div id="app"> <p v-if="otp">Your OTP is: {{ otp }}</p> <button @click="generateOTP">Generate OTP</button> </div> <script type="module"> const app = new Vue({ el: "#app", data() { return { otp: null, } }, methods: { generateOTP() { let digits = '0123456789'; let otp = ''; for (let i = 0; i < 6; i++) { otp += digits[Math.floor(Math.random() * 10)]; } this.otp = otp; }, }, }); </script> </body> </html>