H
H
HitGirl2021-06-07 21:12:41
Vue.js
HitGirl, 2021-06-07 21:12:41

Why doesn't v-model work?

Hello!
I'm trying to use v-model with my component, please tell me why the searchText property does not change?

//MyInput.vue
<template>
  <input type="text" class="search">
</template>

<script>
export default {
  model: {
    prop: 'value',
    event: 'input'
  }
}
</script>


<my-input v-model="searchText" />

      <button >
        {{ searchText }}
      </button>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vadim, 2021-06-07
@HitGirl

Short answer:
1) Set the input attribute value props value via v-bind
2) you need to emit an input event with a new value value when the input event occurs
More:
https://kirillurgant.com/notes/creating-custom-inp...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question