Skip to content

Instantly share code, notes, and snippets.

@SidneyAllen
Last active November 11, 2021 16:54
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 SidneyAllen/8df9c057573fcd820ee65e05ea479ced to your computer and use it in GitHub Desktop.
Save SidneyAllen/8df9c057573fcd820ee65e05ea479ced to your computer and use it in GitHub Desktop.
<script>
import { ref } from "vue";
import Autocomplete from 'vue3-autocomplete'
import useAddressSuggestions from "./useAddressSuggestions";
export default {
name: "App",
components: {
Autocomplete
},
setup () {
const address = ref()
const city = ref()
const state = ref()
const zip = ref()
const suggestions = ref([])
// insert selected function
function selected(suggestion) {
address.value.setText(suggestion.data.primary_line)
city.value = suggestion.data.city
state.value = suggestion.data.state
zip.value = suggestion.data.zip_code
suggestions.value = []
}
const { getSuggestions } = useAddressSuggestions()
async function onAddressInput (val) {
suggestions.value = await getSuggestions(val)
}
return {
address,
city,
state,
zip,
onAddressInput,
suggestions,
getSuggestions,
// insert selected prop
selected
}
}
};
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment