vue2-autocomplete-js does not work as mentioned in documentation

断了今生、忘了曾经 提交于 2020-01-15 09:41:14

问题


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.

来源:https://stackoverflow.com/questions/53949995/vue2-autocomplete-js-does-not-work-as-mentioned-in-documentation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!