mirror of
https://github.com/tenrok/vue-select.git
synced 2026-06-01 05:54:03 +03:00
add ajax to docs
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
<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>
|
||||
Reference in New Issue
Block a user