我的vue版本为2.9.3
我正在尝试从REST API URL中获取名称:
http://192.168.1.3/api/clinic/patients?q=s
将返回以S
开头的患者的姓名。
默认情况下,它以q
作为参数,请参见docs
按照文档,我实现了它,如下所示:
<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>
和脚本中
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.
},
getData
从未被调用。请帮忙。而且自动完成功能根本无法正常工作。