Vue.js Vue选择所选选项

Vue.js Vue选择所选选项,vue.js,vuejs2,vue-component,vue-select,Vue.js,Vuejs2,Vue Component,Vue Select,我在做一个客户服务ABM。对于用户搜索,我使用Vue Select筛选并选择正确的客户。。。Vue Select从我的客户api获取客户列表,然后我将数据提取到Vue Select中。用户可以筛选以获得正确的客户 我需要知道的是,当我想要编辑服务时,如何分配所选的客户端。当用户在编辑模式下按下Service Edit(服务编辑)打开模式时,将调用/Service/{id}以获取服务信息。包含所有服务信息和客户ID的服务响应。。。问题是,如果我把它作为defaul selected 以下是我的vu

我在做一个客户服务ABM。对于用户搜索,我使用Vue Select筛选并选择正确的客户。。。Vue Select从我的客户api获取客户列表,然后我将数据提取到Vue Select中。用户可以筛选以获得正确的客户

我需要知道的是,当我想要编辑服务时,如何分配所选的客户端。当用户在编辑模式下按下Service Edit(服务编辑)打开模式时,将调用/Service/{id}以获取服务信息。包含所有服务信息和客户ID的服务响应。。。问题是,如果我把它作为defaul selected

以下是我的vuejs信息:

My searchCustomers功能,将数据提取到选项中:

searchCustomers(search){

            let searchVal = search.split(' ').join('+');

            axios.get('api/customer?nomina=&filter=' + searchVal)
            .then((response) => {
              this.options = response.data['data'];
            })
            .catch(function (error) {
              console.log(error);
            })
          },
新服务模式,用于从api获取数据:

newEditServiceModal(id){

            this.editMode = true;

            this.$Progress.start();

            this.service.clear();
            this.service.reset();

            axios.get('api/service/' + id)
            .then((data) => {
              this.service.fill(data.data)
            })
            .catch(() => {
              this.$Progress.fail();
            })

            $('#serviceModal').modal('show');

          },
最后是我的v-select组件:

<v-select 
  :options="options" 
  @search="searchCustomers" 
  :filterable="false" 
  v-model="service.id_customers" 
  :class="{ 'is-invalid': service.errors.has('customer.id') }"
>
  <template 
    slot="no-options"
  >
    Buscar un cliente...
  </template>

  <template 
    slot="option" 
    slot-scope="option"
  >
    <div class="d-center">
    {{ option.id + ' - ' + option.name }}
    </div>
  </template>

  <template 
    slot="selected-option" 
    slot-scope="option" 
    :value="option.id" 
    v-model="service.id_customers"
  >
    <div class="selected d-center">
      {{ option.id + ' - ' + option.name }}
    </div>
  </template>
</v-select>

传递id并将正确的客户分配给v-form的正确方法是什么?

类似的方法应该可以做到这一点。这显示了如何将选定值分配到表单字段中。对于输入,诀窍是在其上使用v模型。。例子如下

编辑:更新我的答案以便使用插槽

这有助于回答你的问题,还是我误解了

如果我是你的话,我会温习一下——这非常有帮助

[]

Vue.component'v-select',VueSelect.VueSelect 新Vue{ el:应用程序, 数据:{ 选定:, 选项:[{ id:1, 姓名:Guido Caffa }, { id:2, 姓名:无名氏 }] } } {{option.id}}-{{option.name} {{option.id}}-{{option.name} 选定项目: 姓名: 身份证件:
我不理解您的需要,但您必须使用map或foreach并在选项中显示它