S
S
shasoft2019-09-28 13:34:53
Vue.js
shasoft, 2019-09-28 13:34:53

How to update v-model="value" if value is an array?

I made my own component. The input value is an array. I specify v-model="tags" where

data: function() {
  return {
    tags : ['1','2','3'] 
 }
}

In my component, I change element 1 and send the message emit('input',['1','new value','3']), but the value of tags in the parent component does not change. More precisely, it seems to be changing, but not redrawn but not redrawn in {{ JSON.stringify(tags) }}
made
v-bind:value="tags"
v-on:input="onInput"
and in onInput
onInput: function(newValue) {
      console.log("newValue", newValue);
      this.tags = newValue;
    }

And in the console I see that the message is coming and the function is working, but nothing happens. Moreover, if you add this.tags('!!!') to the end of the function, then the value is updated.
I just can’t figure out what and where to tweak in my component so that everything is updated.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question