vue2-autocomplete-js does not work as mentioned in

2019-08-01 18:59发布

问题:

I have vue version 2.9.3

I am trying to get names from a REST API URL: http://192.168.1.3/api/clinic/patients?q=s

will return name of patients starting with S.

it by default takes q as parameter see docs

And following the docs I implemented it like shown below:

<template>
  <div>
    <div class="alignLabel">
      <label for="patientName">
        <span>Patient Name <span class="required">*</span></span>
      </label>
    </div>
    <div>
    <autocomplete
      url="http://192.168.1.3/api/clinic/patients"
      anchor="title"
      label="writer"
      :on-select="getData">
    </autocomplete>
  </div>
</template>

and in script:

var $ = window.jQuery = require('jquery')
import Vue from 'vue'
import Autocomplete from 'vue2-autocomplete-js';
Vue.use(Autocomplete)
require('vue2-autocomplete-js/dist/style/vue2-autocomplete.css');
export default {
  name: 'Attend',
  data : function (){ },
  components: {
    'vue-datetimepicker': vuedatetimepicker,
    'autocomplete': Autocomplete,
  },
  methods: {
    getData(obj){
        console.log(obj); // this method is never getting called.
    },

the getData is never getting called. Please help. and autocomplete is not working at all.