screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html> <head> <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> </head> <body> <h2>Vue Js Get Element by ref </h2> <div id="app"> <input type="text" ref="myInput" v-model="inputValue" /> <button @click="handleClick">Submit</button> </div> <script> new Vue({ el: '#app', data() { return { inputValue: '' }; }, methods: { handleClick() { const myInput = this.$refs.myInput; const inputValue = myInput.value; alert(`Input value is: ${inputValue}`); } } }); </script> <style scoped> input[type="text"] { padding: 10px; font-size: 18px; border: 2px solid #ccc; border-radius: 5px; margin-right: 10px; } button { padding: 10px 20px; background-color: #4CAF50; color: white; border: none; border-radius: 5px; cursor: pointer; } button:hover { background-color: #3e8e41; } button:active { background-color: #2980B9; } </style> </body> </html>