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 Js Watch Property </h3> <label>First Name:</label> <input type="text" v-model="firstName"> <label>Last Name:</label> <input type="text" v-model="lastName"> <p>Full Name: {{ fullName }}</p> </div> <script type="module"> const app = Vue.createApp({ data() { return { firstName: '', lastName: '', fullName: '' } }, watch: { firstName: function (newVal, oldVal) { this.fullName = this.firstName + ' ' + this.lastName; }, lastName: function (newVal, oldVal) { this.fullName = this.firstName + ' ' + this.lastName; } } }); app.mount('#app'); </script> <style scoped> #app { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100vh; } label { margin-bottom: 0.5rem; font-weight: bold; } input[type="text"] { padding: 0.5rem; border: 1px solid #ccc; border-radius: 0.25rem; margin-bottom: 1rem; } p { font-weight: bold; } </style> </body> </html>