Len Joseph
Len Joseph

Reputation: 1458

Input fields not working in Vue with v-model

I have the following template syntax in a Vue single-file component:

<template>
   ...
   <input v-model="newInput">
   ...
</template>

In the same component, I have this data:

<script>
   ...
   data: () => {
     return {
      newInput: "",
     }
   }
   ...
</script>

Problem: In Chrome, this input field will not accept any text or numbers. The cursor is blinking in the field, but no text is entering. I opened dev tools, and there is no data change when I type. I checked my keyboard settings, nothing weird there.

Appreciate any guidance on this!

Upvotes: 1

Views: 4201

Answers (1)

AddWeb Solution Pvt Ltd
AddWeb Solution Pvt Ltd

Reputation: 21681

In my case this work perfectly,

Here in template tag I've modified input and in the script tag I've modified 'data()' method which accept any text or number.

Try this:

<template>

   <input type="text" v-model="newInput">

</template>


<script>

export default {
  data () {
    return {
      newInput: ''
    }
  }
}
</script>

Upvotes: 2

Related Questions