[Vuejs]-Vue.js multi select change options inside axios GET

0👍

Finally I found the answer. We need to swapp the positions of options and value of component watch.

watch: {
    options: function (options) {
      // update options
      $(this.$el).select2({ data: options })
    },
    value: function (value) {
       if ([...value].sort().join(",") !== [...$(this.$el).val()].sort().join(","))
        $(this.$el).val(value).trigger('change');
    }
  },
👤vimuth

Leave a comment