[Vuejs]-Prevent Vue Multiple Select to Store an Empty Array

1👍

You could add watcher and when length becomes 0 just add previous value.

  watch: {
    model(val, oldVal) {
      if(val.length == 0 && oldVal.length > 0) {
        // take only one item in case there's clear button or etc.
        this.model = [oldval[0]];
      }
    }
  }

Leave a comment