我是Vue2的新手,我正尝试使用https://www.npmjs.com/package/vue2-autocomplete-js组件并面临问题:
触发:on-select
事件后,它会清除输入的值,而我找不到找到方法来保留它。
我的完整示例:
<autocomplete
url="https://geocode-maps.yandex.ru/1.x/"
anchor="GeoObject.name"
label="GeoObject.description"
param="geocode"
id="address_input"
:custom-params="{ format: 'json' }"
:process="processJSON"
:classes="{ input: 'form-control'}"
:on-select="fillAddressData"
:debounce="500">
</autocomplete>
var vm = new Vue( {
el: '#events-form',
data: {
processJSON: function ( json ) {
return json.response.GeoObjectCollection.featureMember;
},
fillAddressData: function ( json ) {
json.GeoObject.metaDataProperty.GeocoderMetaData.Address.Components.forEach( function ( el ) {
if ( el.kind === "locality" ) {
vm.city_text = el.name;
}
});
vm.coord1 = json.GeoObject.Point.pos.split( " " )[ 0 ];
vm.coord2 = json.GeoObject.Point.pos.split( " " )[ 1 ];
},
city_text: "",
coord1: "",
coord2: "",
address_text: "",
},
components: {
autocomplete: Vue2Autocomplete.default
}
});
请帮助我!