Vue

by shubhampokhriyal

HTML

<div id="app">
  <div>
    <testcom :functionname="testFunc1" :testval="2227" :darray="dataArray" :idVal="client_id"/>

  </div>
</div>

CSS

body {
  background: #20262E;
  padding: 20px;
  font-family: Helvetica;
}

#app {
  background: #fff;
  border-radius: 4px;
  padding: 20px;
  transition: all 0.2s;
}

li {
  margin: 8px 0;
}

h2 {
  font-weight: bold;
  margin-bottom: 15px;
}

del {
  color: rgba(0, 0, 0, 0.3);
}

Vue

Vue.component('testcom',{
  props: ['functionname','testval','darray','idVal'],
  template: `
    <div>
<select v-model="idVal" @change="functionname(idVal)">
<option v-for="(da,index) in darray" :key="index">{{da.name}}</option>
</select>
{{idVal}}
</div>

  `
})
new Vue({
  el: '#app',
  data:{
    client_id:'',
    client_id1:'',
    dataArray:[
                {id:1,name:'shubham'},
                {id:2,name:'rishab'},
                {id:3,name:'pranav'}
              ]
  },
  methods: {
    testFunc(value){
      alert(value);
      return value;
    },
    testFunc1(value){
      alert(value+'====1');
      return value;
    }
  }
})