user3599803
user3599803

Reputation: 7034

vue select component - set defaults props?

I use this vue-multiselect plugin: https://vue-multiselect.js.org/
Since I'm going to use it many times, I want to set some defaults props.

For example I want the selectLabel prop to be an empty string, and maybe to sets some <slot>s.

In a typical jQuery plugin I could use $.plugin.defaults to set the defaults. How to do the same with vue plugins?

Upvotes: 1

Views: 864

Answers (1)

Roy J
Roy J

Reputation: 43899

You can use extends to subclass your component. Pass it a spec just like you would use when defining a component, but only supply the things you want to provide defaults for.

<script>
  import Multiselect from 'vue-multiselect';

  export default {
    extends: Multiselect,
    props: {
      selectLabel: {
        type: String,
        default: ''
      }
    }
  }
</script>

Upvotes: 5

Related Questions