[Vuejs]-How can I display value edited in combobox dynamic on the vue component?

0👍

Option 1 – Add a watcher

The problem is you only set selected: this.value || '' in your data when the component is initialized. To have it update, you need to add a watcher too, like so:

watch: {
  value(newValue) {
    this.selected = newValue;
  }
}

This will update the selected prop in child each time the one in parent changes.

Option 2 – Refer directly to the prop

You can get rid of selected altogether and just use value in the child. It will always remain up to date with the parent.

Leave a comment