screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html> <head> <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script> </head> <body> <div id="app"> <h3>Vue Add Two Numbers</h3> <label for="num1">Enter number 1:</label> <input type="number" id="num1" v-model="num1"> <br> <label for="num2">Enter number 2:</label> <input type="number" id="num2" v-model="num2"> <br> <button @click="sum">Add numbers</button> <p>Result: {{ result }}</p> </div> <script type="module"> const app = Vue.createApp({ data() { return { num1: 2, num2: 4, result: 0 } }, methods: { sum() { this.result = parseInt(this.num1) + parseInt(this.num2); } } }); app.mount('#app'); </script> <style scoped> #app { font-family: Arial, sans-serif; padding: 20px; } label { display: inline-block; margin-bottom: 5px; } input[type="number"] { padding: 5px; border: 1px solid #ccc; border-radius: 3px; margin-bottom: 10px; } button { background-color: #4CAF50; color: white; border: none; padding: 10px 20px; border-radius: 3px; cursor: pointer; } button:hover { background-color: #3e8e41; } p { font-weight: bold; margin-top: 10px; } </style> </body> </html>