I just installed vue-instant to make an auto suggestion for search and get an example code like this
https://jsfiddle.net/santiblanko/dqo6vr57/
My question is how to move components 'vue-instant': VueInstant.VueInstant to a new Vue component like this one:
Vue.component('vue-instant-component', {
//vue-instant
}
I've tried something like this:
Vue.component('vue-instant', {
data: {
value: '',
suggestionAttribute: 'original_title',
suggestions: [],
selectedEvent: ""
},
methods: {
clickInput: function() {
this.selectedEvent = 'click input'
},
clickButton: function() {
this.selectedEvent = 'click button'
},
selected: function() {
this.selectedEvent = 'selection changed'
},
enter: function() {
this.selectedEvent = 'enter'
},
keyUp: function() {
this.selectedEvent = 'keyup pressed'
},
keyDown: function() {
this.selectedEvent = 'keyDown pressed'
},
keyRight: function() {
this.selectedEvent = 'keyRight pressed'
},
clear: function() {
this.selectedEvent = 'clear input'
},
escape: function() {
this.selectedEvent = 'escape'
},
changed: function() {
var that = this;
this.suggestions = [];
axios.get('https://api.themoviedb.org/3/search/movie?api_key=342d3061b70d2747a1e159ae9a7e9a36&query=' + this.value)
.then(function(response) {
response.data.results.forEach(function(a) {
that.suggestions.push(a)
});
});
}
}
})
but it doesn't work
componentsblock at the end of your fiddle, you can callVue.component('vue-instant', VueInstant.VueInstant);before constructing theVueinstance to register it.suggestionAttribute is not definedVueInstantwith some defaults?Vue.component (). The code should not innew Vue()but inVue.component ()