Vue 3
ActiveComposition API + @postio/address-finder mounted via a template ref.
Install
npm i @postio/address-finder
30-second example
<script setup lang="ts">
import { onMounted, ref } from 'vue';
import { setup as setupFinder } from '@postio/address-finder';
const inputEl = ref<HTMLInputElement | null>(null);
onMounted(() => {
if (!inputEl.value) return;
setupFinder({
apiKey: import.meta.env.VITE_POSTIO_KEY,
input: inputEl.value,
output: {
address_line_1: '#line1',
post_town: '#town',
postcode: '#postcode',
},
});
});
</script>
<template>
<input ref="inputEl" placeholder="Start typing an address…" />
<input id="line1" />
<input id="town" />
<input id="postcode" />
</template>