Search code examples
vue.jsv-select

onchange pass selected option in input vue


guys, I m new to Vue I found lots of solution but none of them seems to work with my situation.I m using Vue-select (sagalbot ) below is my code here is my code

  <v-select v-model="productvalue"   multiple  label="category_desc" :options="options1"    :on-change="onChange" ></v-select>
  <div class="input-group" v-for="field in fields">
    <input type="text" v-model="field.sensitive"> 
 </div>

export default {
name: 'List Purches',
 data(){
  return{
  productvalue:[],
  finds: [],
  options1:[]
 }

},
methods:{
getCategories(){
var _this=this
  this.$http.get('http://localhost:3000/api/categories') .then(function 
    (response) {
         _this.options1=response.data;
        })
        .catch(function (error) {
          console.log("error.response");
        });
     },


   onChange: function (){    
   //here i m try to access selected input value
     this.finds.push({value: '' });  
       },
   }, 
 }

how i can pass selected option of v-select into created input


Solution

  • This v-select's onChange function accept a parameter which is a array contains the selected options.

    By the way, your can use this codes, open Chrome console to debugger the value of 'a','b','c'.

    onChange(a,b,c) {
          debugger;
          console.log(a);
    }