Skip to content

Instantly share code, notes, and snippets.

@jonathanharrell
Last active July 7, 2018 20:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonathanharrell/f83516b423f74105434b1bd5ff346e15 to your computer and use it in GitHub Desktop.
Save jonathanharrell/f83516b423f74105434b1bd5ff346e15 to your computer and use it in GitHub Desktop.
Vue SearchSelect Component (with scoped slots)
Vue.component('search-select', {
props: [
'options',
'filterMethod'
],
data () {
return {
query: ''
}
},
computed: {
results () {
return this.filterMethod(this.options, this.query)
}
},
methods: {
setQuery (event) {
this.query = event.target.value
}
},
render () {
return this.$scopedSlots.default({
results: this.results,
searchList: (event) => {
this.setQuery(event)
}
})
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment