0

在使用@input更改组件 Vue Multiselect 的值后,我尝试启动一个方法,但出现以下编译错误:

CS0103:当前上下文中不存在名称“输入”

这是我的多选:

<multiselect v-model="Instalacao.value" label="Serie" track-by="Serie" placeholder="Nº de série" :options="Instalacoes"
    :multiple="false" :searchable="true" :allow-empty="false" :disabled="Editando" @input="getTecnicosByRepresentante">
    <span slot="noResult">Nenhum técnico encontrado</span>
</multiselect>
4

1 回答 1

1

此示例按预期工作:当您选择一个值时, thewatch和处理程序都会执行。@input您的问题可能不在您在此处包含的代码中。

new Vue({
  el: '#app',
  components: {
    Multiselect: window.VueMultiselect.default
  },
  data: {
    Instalacao: {
      value: null
    },
    Instalacoes: [{
        Serie: 'one',
        value: 'Vue.js'
      },
      {
        Serie: 'two',
        value: 'Vue-Multiselect'
      },
      {
        Serie: 'three',
        value: 'Vuelidate'
      }
    ]
  },
  watch: {
    'Instalacao.value': function(newValue) {
      console.log('Updated', newValue);
    }
  },
  methods: {
    getTecnicosByRepresentante() {
      console.log("Input detected, too");
    }
  }
})
<script src="https://unpkg.com/vue@latest/dist/vue.js"></script>
<link href="https://unpkg.com/vue-multiselect@latest/dist/vue-multiselect.min.css" rel="stylesheet" />
<script src="https://unpkg.com/vue-multiselect@latest/dist/vue-multiselect.min.js"></script>
<div id="app">
  <multiselect v-model="Instalacao.value" label="Serie" track-by="Serie" placeholder="Nº de série" :options="Instalacoes" :multiple="false" :searchable="true" :allow-empty="false" @input="getTecnicosByRepresentante">
    <span slot="noResult">Nenhum técnico encontrado</span>
  </multiselect>
  <pre>{{ Instalacao.value }}</pre>
</div>

于 2019-01-15T14:30:12.073 回答