Sunkhern
Sunkhern

Reputation: 278

v-model on textarea overwriting content

Learning Vue, I'm iterating through an object and I want to be able to display some content in each textarea and identify the textarea individually for updating etc, but I have an issue as v-model fills it with the identifier number.

I tried to include the content directly in the textarea with {{}}, v-model overwrites it.

my code is pretty simple:

textarea.text(v-model="index")
    | {{content.value}}

I end up with my fields filled with just a number while I would want content.value for instance

Upvotes: 1

Views: 3104

Answers (1)

Georgi Antonov
Georgi Antonov

Reputation: 1641

<textarea   
    :value="textareaValue"
    @input="input($event.target.value)"
    @focus="onFocus"
    @blur="onBlur"
>

Where input is the method where you do something with the text when you write. and :value is the text which is displayed ( initial lets say).

You can wrap this inside your compoennt my-textarea. Just be sure to emit the value inside your input method, and set value prop.

  <my-textarea
        v-model="parentValue"
></my-textarea>

Upvotes: 3

Related Questions