mirror of
https://github.com/tenrok/vue-select.git
synced 2026-05-17 02:29:37 +03:00
38 lines
884 B
Vue
38 lines
884 B
Vue
<template>
|
|
<div>
|
|
<p><v-select :debounce="250" :options="options" :on-search="getOptions" placeholder="Search GitHub Repositories..." label="full_name"></v-select></p>
|
|
|
|
<div v-if="error" class="alert alert-warning" role="alert">
|
|
<button type="button" class="close" @click="error = null">
|
|
<span aria-hidden="true">×</span></button>
|
|
{{ error.message }}
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script type="text/babel">
|
|
export default {
|
|
data() {
|
|
return {
|
|
repo: null,
|
|
error: null,
|
|
options: null
|
|
}
|
|
},
|
|
|
|
methods: {
|
|
getOptions(search, loading) {
|
|
loading(true)
|
|
this.$http.get('https://api.github.com/search/repositories', {q: search})
|
|
.then(resp => {
|
|
this.options = resp.data.items
|
|
loading(false)
|
|
})
|
|
.catch(err => {
|
|
this.error = err.data
|
|
loading(false)
|
|
})
|
|
}
|
|
}
|
|
}
|
|
</script> |