Component vuejs2 setting default value and then passing that back to the parent

54 Views Asked by At

Update: I have some vue code, main.vue which I would like to call a component, which does three things:

  1. Allows the user to pass to the component a set of items, one of which can be selected in the component pulldown, using the v-select and v-model API.
  2. Pass to the component the default pulldown item
  3. Then communicate back to the parent the selected option from the component's pull-down.

So for example, I can call the component in the main.vue (parent):

<componentPullDown :items="customers", :defaultSelected="preferredCustomer"/>

Then within the componentPullDown vue component, I have the

      <div class="box">
      <span class="box-header">Speciality</span>
      <v-select
        label="customer"
        :options="items"
        :clearable="false"
        :item-text="preferredCustomer"           
        v-model="selectedCustomer"
        return-object
      />
      <span class="box-label">
      </span>
    </div>

I have the options for the list working fine, but I can't get the default value to work, or communicate back to the parent the option selected when the pulldown item has changed.

Thanks. Any help would be great.

0

There are 0 best solutions below