2
0
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:
Jeff Sagal
2016-06-15 20:34:38 -07:00
parent 480bfc1c5f
commit bfae6b3068
11 changed files with 430 additions and 56 deletions
+38
View File
@@ -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">&times;</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>