screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html> <head> <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script> </head> <body> <h2>Vue Sleep for 1 Seconds </h2> <div id="app"> <button @click="changeColor" :style="{ backgroundColor: buttonColor }">Click me</button> </div> <script type="module"> const app = Vue.createApp({ data() { return { buttonColor: 'blue' }; }, methods: { async changeColor() { this.buttonColor = 'red'; await this.sleep(1000); this.buttonColor = 'blue'; }, sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)); } } }); app.mount("#app"); </script> <style scoped> button { padding: 10px 20px; font-size: 16px; border: none; border-radius: 5px; cursor: pointer; transition: background-color 0.3s ease; } button:hover { background-color: #007bff; color: #fff; } </style> </body> </html>