I want to get a string input and display it, along with the number of characters of the string.
Need help to implement.
<section id="app"> <h2>Learn Vue Works</h2> <input type="text" @input="saveInput"> <button @click="setText">Set Text</button> <br> <p>{{ qry }} {{ message }}</p>
====app.js====================================== p>
const app = Vue.createApp({ data() { return { message: 'Vue is great!', qry: 'Query String : ', currentSearchInput: '', }; }, methods: { setText() { this.message = this.currentUserInput; }, saveInput(event) { this.currentUserInput = event.target.value; }, }, }); app.mount('#app');
Thanks in advance.
Use v-model to bind
currentSearchInput
to the input. You don't need tosaveInput
at all.Your code has
currentSearchInput
andcurrentUserInput
. typo?