LoginSignup
0
0

【VueJS】郵便番号から住所検索するライブラリ

Last updated at Posted at 2023-03-28

yubinbango-core2というライブラリを使用し、郵便番号から住所検索を実現します。

環境
laravel9
Vue.js3

インストール

npm i yubinbango-core2@^0.6.3

packege.jsonに追記されていればOKです。

image.png

コード

Create.vue
<script setup>
    import { Core as YubinBangoCore } from "yubinbango-core2";

// 数字を文字に変換 第1引数が郵便番号
// 第2がコールバックで引数に住所
const fetchAddress = () => {
    new YubinBangoCore(String(form.postcode), (value) => {
    form.address = value.region + value.locality + value.street
    })
}

</script>

<template>
    <input name="postcode" @change="fetchAddress">
    <input name="address">
</template>
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0